poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] Don't crash if editor produced an empty file.


From: John Darrington
Subject: [PATCH 4/5] Don't crash if editor produced an empty file.
Date: Mon, 11 Nov 2019 15:00:45 +0100

2019-11-11 John Darrington <address@hidden>

      * src/pk-editor.c (pk_cmd_editor): Initialize newline
---
 src/pk-editor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pk-editor.c b/src/pk-editor.c
index 890a6df..b4fe37c 100644
--- a/src/pk-editor.c
+++ b/src/pk-editor.c
@@ -78,11 +78,11 @@ pk_cmd_editor (int argc, struct pk_cmd_arg argv[], uint64_t 
uflags)
   if (ret == 0
       && (f = fopen (tmpfile, "r")) != NULL)
     {
-      char *newline = NULL;
+#define STEP 128
+      char *newline = xmalloc (STEP);
       size_t size, i = 0;
       int c;
 
-#define STEP 128
       for (size = STEP; (c = fgetc (f)) != EOF; i++)
         {
           if (i % STEP == 0)
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]