From f9e2884809cd6f0e11f76b25af9b09047aa9a800 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Feb 2025 14:30:34 -0500 Subject: Gracefully handle failing return from ftell() Again I don't think this is actually a concern, but it appeases clang-tidy. --- examples/pugl_vulkan_cpp_demo.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples/pugl_vulkan_cpp_demo.cpp') 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(ftell(file.get())); + const auto filePos = ftell(file.get()); + if (filePos <= 0) { + return {}; + } + + const auto fileSize = static_cast(filePos); fseek(file.get(), 0, SEEK_SET); const auto numWords = fileSize / sizeof(uint32_t); -- cgit v1.2.1