diff options
author | David Robillard <d@drobilla.net> | 2022-08-08 23:31:49 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-09-28 12:23:38 -0400 |
commit | 727b6835a63d2a163dae434e1090a14aa7011373 (patch) | |
tree | 428444590287790501e8f3f1560336b1fa9f924e /examples/pugl_vulkan_cpp_demo.cpp | |
parent | c3bc53d45d26363da38ede93eaeb9aa6145643e3 (diff) | |
download | pugl-727b6835a63d2a163dae434e1090a14aa7011373.tar.gz pugl-727b6835a63d2a163dae434e1090a14aa7011373.tar.bz2 pugl-727b6835a63d2a163dae434e1090a14aa7011373.zip |
Handle fread() errors in examples
Diffstat (limited to 'examples/pugl_vulkan_cpp_demo.cpp')
-rw-r--r-- | examples/pugl_vulkan_cpp_demo.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp index 69f360d..c901de5 100644 --- a/examples/pugl_vulkan_cpp_demo.cpp +++ b/examples/pugl_vulkan_cpp_demo.cpp @@ -692,7 +692,10 @@ readFile(const char* const programPath, const std::string& filename) const auto numWords = fileSize / sizeof(uint32_t); std::vector<uint32_t> buffer(numWords); - fread(buffer.data(), sizeof(uint32_t), numWords, file.get()); + if (fread(buffer.data(), sizeof(uint32_t), numWords, file.get()) != + numWords) { + buffer.clear(); + } return buffer; } |