commit 8842cdf842e4b201c5d411efca8f37776941d0ee
parent f52f8db7d5b6cbda63469a33daf5af4ef7f85be8
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date: Fri, 21 Jun 2024 21:31:08 +0200
feat(import): improve error handling
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/import.c b/src/import.c
@@ -15,7 +15,12 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid
rewind(pfile);
char* ics = malloc(ics_bytes + 1);
- fread(ics, 1, ics_bytes, pfile);
+ size_t read = fread(ics, 1, ics_bytes, pfile);
+ if (read < ics_bytes) {
+ perror("Error while reading in ics_import()");
+ fclose(pfile);
+ return;
+ }
fclose(pfile);
ics[ics_bytes] = '\0';
@@ -118,4 +123,4 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid
free(vevent_desc);
}
free(ics);
-}
-\ No newline at end of file
+}