You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-text/paps/files/paps-0.6.8-fix-empty-file.p...

24 lines
540 B

https://bugs.gentoo.org/show_bug.cgi?id=566050#c2
--- a/src/paps.c
+++ b/src/paps.c
@@ -569,11 +569,14 @@
fclose (file);
- /* Add a trailing new line if it is missing */
- if (inbuf->str[inbuf->len-1] != '\n')
- g_string_append(inbuf, "\n");
+ if (inbuf->len) {
+ /* Add a trailing new line if it is missing */
+ if (inbuf->str[inbuf->len-1] != '\n')
+ g_string_append(inbuf, "\n");
- text = inbuf->str;
+ text = inbuf->str;
+ } else
+ text = g_strdup("\n");
g_string_free (inbuf, FALSE);
return text;