diff options
author | Ariadna Vigo <arivigodr@gmail.com> | 2020-11-14 15:21:49 +0100 |
---|---|---|
committer | Ariadna Vigo <arivigodr@gmail.com> | 2020-11-14 15:21:49 +0100 |
commit | 39bb29ab42023f8ae62c3210fc6990fead2628d3 (patch) | |
tree | 964ea18d7695e0b930cd48b88e46850e98efff06 | |
parent | f337143f0276c905c269e87a99d33aec0ac773bd (diff) |
Fixed corruption by blank lines
-rw-r--r-- | cras.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; } |