From f6314ba4d6a004270fc11f67ddaaa8d788050c03 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Mon, 28 Oct 2019 18:10:32 +0000 Subject: [PATCH] render: zero terminate shader code --- src/render.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/render.c b/src/render.c index 1b642cd..509001d 100644 --- a/src/render.c +++ b/src/render.c @@ -192,6 +192,14 @@ static char* read_file(const char* path) if (ferror(stream)) goto read_failure; + if (rsize == size) { + contents = realloc(contents, size + 1); + if (!contents) + goto read_failure; + } + + contents[rsize] = '\0'; + fclose(stream); return contents;