diff options
author | David Robillard <d@drobilla.net> | 2025-02-06 14:30:34 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-02-06 14:32:55 -0500 |
commit | f9e2884809cd6f0e11f76b25af9b09047aa9a800 (patch) | |
tree | 314d7e8405b29c445cf5eed724e55506ff4c2172 /examples/pugl_vulkan_cpp_demo.cpp | |
parent | 40baf35b078b841cefbc55487b657aee25ee3b5f (diff) | |
download | pugl-f9e2884809cd6f0e11f76b25af9b09047aa9a800.tar.gz pugl-f9e2884809cd6f0e11f76b25af9b09047aa9a800.tar.bz2 pugl-f9e2884809cd6f0e11f76b25af9b09047aa9a800.zip |
Gracefully handle failing return from ftell()
Again I don't think this is actually a concern, but it appeases clang-tidy.
Diffstat (limited to 'examples/pugl_vulkan_cpp_demo.cpp')
-rw-r--r-- | examples/pugl_vulkan_cpp_demo.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp index a1d6954..52976e6 100644 --- a/examples/pugl_vulkan_cpp_demo.cpp +++ b/examples/pugl_vulkan_cpp_demo.cpp @@ -715,7 +715,12 @@ readFile(const char* const programPath, const std::string& filename) } fseek(file.get(), 0, SEEK_END); - const auto fileSize = static_cast<size_t>(ftell(file.get())); + const auto filePos = ftell(file.get()); + if (filePos <= 0) { + return {}; + } + + const auto fileSize = static_cast<size_t>(filePos); fseek(file.get(), 0, SEEK_SET); const auto numWords = fileSize / sizeof(uint32_t); |