From cceaa04ef23d766bc666324e69b8fa6fbfa1e39a Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 31 Aug 2011 13:43:38 +0200 Subject: GOB: Make Util::setExtension() not add an extension to an empty string --- engines/gob/util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 1add604ccb..58dfc9c7ad 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -518,6 +518,11 @@ void Util::deleteList(List *list) { } char *Util::setExtension(char *str, const char *ext) { + assert(str && ext); + + if (str[0] == '\0') + return str; + char *dot = strrchr(str, '.'); if (dot) *dot = '\0'; @@ -527,6 +532,9 @@ char *Util::setExtension(char *str, const char *ext) { } Common::String Util::setExtension(const Common::String &str, const Common::String &ext) { + if (str.empty()) + return str; + const char *dot = strrchr(str.c_str(), '.'); if (dot) return Common::String(str.c_str(), dot - str.c_str()) + ext; -- cgit v1.2.3