summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadna Vigo <arivigodr@gmail.com>2020-11-14 15:21:49 +0100
committerAriadna Vigo <arivigodr@gmail.com>2020-11-14 15:21:49 +0100
commit39bb29ab42023f8ae62c3210fc6990fead2628d3 (patch)
tree964ea18d7695e0b930cd48b88e46850e98efff06
parentf337143f0276c905c269e87a99d33aec0ac773bd (diff)
Fixed corruption by blank lines
-rw-r--r--cras.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/cras.c b/cras.c
index e2b0deb..2f56d05 100644
--- a/cras.c
+++ b/cras.c
@@ -179,6 +179,16 @@ store_input(TaskLst *list, FILE *fp)
if (linebuf[strlen(linebuf) - 1] == '\n')
linebuf[strlen(linebuf) - 1] = '\0';
+ /*
+ * Ignoring blank lines so that the file doesn't get corrupted
+ * by one. We calculate strlen(linebuf) again because we
+ * *might* have chomped '\n' or not. Storing the size
+ * beforehand is not a viable optimization, as far as I can
+ * see.
+ */
+ if (strlen(linebuf) == 0)
+ continue;
+
if (task_lst_add_task(list, TASK_TODO, linebuf) < 0)
return -1;
}