aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pugl_shader_demo.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-08 23:31:49 -0400
committerDavid Robillard <d@drobilla.net>2022-09-28 12:23:38 -0400
commit727b6835a63d2a163dae434e1090a14aa7011373 (patch)
tree428444590287790501e8f3f1560336b1fa9f924e /examples/pugl_shader_demo.c
parentc3bc53d45d26363da38ede93eaeb9aa6145643e3 (diff)
downloadpugl-727b6835a63d2a163dae434e1090a14aa7011373.tar.gz
pugl-727b6835a63d2a163dae434e1090a14aa7011373.tar.bz2
pugl-727b6835a63d2a163dae434e1090a14aa7011373.zip
Handle fread() errors in examples
Diffstat (limited to 'examples/pugl_shader_demo.c')
-rw-r--r--examples/pugl_shader_demo.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/pugl_shader_demo.c b/examples/pugl_shader_demo.c
index 8f2c2e7..d018db3 100644
--- a/examples/pugl_shader_demo.c
+++ b/examples/pugl_shader_demo.c
@@ -204,7 +204,11 @@ loadShader(const char* const programPath, const char* const name)
fseek(file, 0, SEEK_SET);
char* source = (char*)calloc(1, fileSize + 1u);
- fread(source, 1, fileSize, file);
+ if (fread(source, 1, fileSize, file) != fileSize) {
+ free(source);
+ source = NULL;
+ }
+
fclose(file);
return source;