diff --git a/glslUtil.c b/glslUtil.c index f151c4c..892f6eb 100644 --- a/glslUtil.c +++ b/glslUtil.c @@ -18,9 +18,14 @@ static char *loadFile(const char *fname) return NULL; char * buff = malloc(st.st_size + 1); FILE *fil = fopen(fname, "r"); - fread(buff, st.st_size, 1, fil); + int bytes_read = fread(buff, st.st_size, 1, fil); fclose(fil); buff[st.st_size] = '\0'; + if (bytes_read != st.st_size) + { + free(buff); + return NULL; + } return buff; }