[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
- [PATCH 1/5] Fix typo in documentation, John Darrington, 2019/11/11
- [PATCH 4/5] Don't crash if editor produced an empty file.,
John Darrington <=
- [PATCH 2/5] Save the readline history in ~/.poke_history, John Darrington, 2019/11/11
- [PATCH 3/5] Don't crash if the scanner fails, John Darrington, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, Jose E. Marchesi, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, John Darrington, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, Jose E. Marchesi, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, John Darrington, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, Jose E. Marchesi, 2019/11/11
- Re: [PATCH 3/5] Don't crash if the scanner fails, John Darrington, 2019/11/11