From 177e0bff0df05c57f00d58a55baba4aa8e0661ec Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Thu, 23 May 2024 21:19:20 -0400 Subject: bugfix: trailing null byte in data from file --- booki.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/booki.c b/booki.c index afca7ed..a90edeb 100644 --- a/booki.c +++ b/booki.c @@ -285,7 +285,7 @@ char* load_file(char* filename) { int size = ftell(fp); rewind(fp); - char* data = malloc(size); + char* data = malloc(size + 1); if (!data) { printf("couldn't malloc\n"); return NULL; @@ -297,6 +297,7 @@ char* load_file(char* filename) { return NULL; } + data[size] = '\0'; fclose(fp); return data; -- cgit v1.2.3