Skip to content

Commit f6002ab

Browse files
authored
getAppName() ensure size of stripped suffix
1 parent d4f25c0 commit f6002ab

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

libs/openFrameworks/utils/ofFileUtils.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,11 @@ class ofFilePath {
452452
/// \returns the App name as native string
453453
static const auto getAppName(bool strip_debug = true) {
454454
auto name = ofFilePath::getCurrentExePathFS().filename().native();
455-
const std::filesystem::path::string_type debug_suffix = "Debug";
455+
typename std::filesystem::path::string_type debug_suffix = std::filesystem::path::string_type("Debug");
456+
auto dbsize = debug_suffix.size();
456457
if (strip_debug) {
457-
if (name.size() > 5 && name.compare(name.size() - 5, 5, debug_suffix) == 0) {
458-
name.erase(name.size() - 5);
458+
if (name.size() > dbsize && name.compare(name.size() -dbsize , dbsize, debug_suffix) == 0) {
459+
name.erase(name.size() - dbsize);
459460
}
460461
}
461462
return name;

0 commit comments

Comments
 (0)