From 6520354a58cfb6d1f2173e2b8f1691d00f55d20d Mon Sep 17 00:00:00 2001 From: Marco Feuerstein Date: Wed, 6 Nov 2024 10:54:14 +0100 Subject: [PATCH] Fix use of uninitialized value. (#5867) If the stat command fails, statbuf is uninitialized. --- code/Common/DefaultIOSystem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index ddb5b3b60..4eedcb0b6 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -104,7 +104,9 @@ bool DefaultIOSystem::Exists(const char *pFile) const { } #else struct stat statbuf; - stat(pFile, &statbuf); + if (stat(pFile, &statbuf) != 0) { + return false; + } // test for a regular file if (!S_ISREG(statbuf.st_mode)) { return false;