aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pugl_vulkan_cpp_demo.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2025-02-06 14:30:34 -0500
committerDavid Robillard <d@drobilla.net>2025-02-06 14:32:55 -0500
commitf9e2884809cd6f0e11f76b25af9b09047aa9a800 (patch)
tree314d7e8405b29c445cf5eed724e55506ff4c2172 /examples/pugl_vulkan_cpp_demo.cpp
parent40baf35b078b841cefbc55487b657aee25ee3b5f (diff)
downloadpugl-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.cpp7
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);