aboutsummaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-12-03 00:04:40 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-12-03 00:04:40 +0000
commit9bbfa7d2cd5b46f07052dfb2212d792cb6f2641d (patch)
tree25841d1585df85161bf91e864c626eb5713dd262 /lib.c
parent623b3acc1f8b719b15523982ff5ed04eb85b19d5 (diff)
downloadobf-9bbfa7d2cd5b46f07052dfb2212d792cb6f2641d.tar.gz
obf-9bbfa7d2cd5b46f07052dfb2212d792cb6f2641d.tar.bz2
obf-9bbfa7d2cd5b46f07052dfb2212d792cb6f2641d.zip
Some general reworking, error handling
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 83f3516..4f79345 100644
--- a/lib.c
+++ b/lib.c
@@ -33,6 +33,14 @@ char *fread_all(FILE *fp)
size_t used, available;
} buffer = {calloc(CHUNK_SIZE, sizeof(*buffer.data)), 0, CHUNK_SIZE};
+ if (!buffer.data)
+ {
+ print_error(
+ "[internal]", 0, 0,
+ "ERROR: Out of Memory (could not allocate buffer in fread_all)");
+ return NULL;
+ }
+
size_t acc = 0, bytes_read = 0;
while ((bytes_read = fread(buffer.data + acc, sizeof(*buffer.data),
CHUNK_SIZE, fp)) != 0)