From 819d1b03419a02b04cedff3f2d5cb7e2f0e03370 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 1 Sep 2022 17:35:40 +0200 Subject: [PATCH] Fixed some potential crashes in ImageComponent caused by invalid theme configuration. --- es-core/src/components/ImageComponent.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index c963a3f3d..75c4907f6 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -146,10 +146,15 @@ void ImageComponent::setImage(const std::string& path, bool tile) if (!mForceLoad && (path[0] == ':') && (path[1] == '/')) { mDynamic = false; } + else if (Utils::FileSystem::isDirectory(path)) { + LOG(LogError) << "ImageComponent: Path is a directory and not a file: \"" << path << "\""; + return; + } - const bool isScalable {path != "" ? Utils::String::toLower(path.substr( - path.size() - 4, std::string::npos)) == ".svg" : - false}; + const bool isScalable { + (path != "" && path.length() > 4) ? + Utils::String::toLower(path.substr(path.size() - 4, std::string::npos)) == ".svg" : + false}; // Create an initial blank texture if needed. if (path.empty() || !ResourceManager::getInstance().fileExists(path)) {