From 069de70654f6850c776b1e5a65c450e062868533 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Sat, 3 Aug 2024 10:29:49 +0100 Subject: [PATCH] Throw if open file with EXV_ENABLE_FILESYSTEM off If ImageFactory::createIo() is called with a file path and has been built with EXV_ENABLE_FILESYSTEM off it returns a NULL pointer. ImageFactory::open() then calls io->open() on this pointer, causing a segfault. The documentation of ImageFactory::createIo does not say it can return a NULL pointer. This commit makes it throw an exception instead of returning a NULL pointer. (cherry picked from commit b0f1c48b180420837dd0663b9ac689c21bd168d0) --- src/image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image.cpp b/src/image.cpp index 589ba434..3504956a 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -831,7 +831,7 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, [[maybe_unuse return std::make_unique(path); #else - return nullptr; + throw Error(ErrorCode::kerFileOpenFailed, path, "", "file access disabled"); #endif } // ImageFactory::createIo