From 5fe5b0dc2680f894aa4f2e712678cb9235c1f64e Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sat, 28 Aug 2021 22:46:13 -0500 Subject: [PATCH] Fix some memory bugs caught by asan --- src/PonscripterLabel_text.cpp | 2 ++ src/ScriptParser.h | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PonscripterLabel_text.cpp b/src/PonscripterLabel_text.cpp index ad945f83..db6c3c85 100644 --- a/src/PonscripterLabel_text.cpp +++ b/src/PonscripterLabel_text.cpp @@ -227,6 +227,8 @@ PonscripterLabel::drawString(const char* str, rgb_t color, Fontinfo* info, continue; } + if (!*str) { break; } + if (*str == 0x0a || (*str == '\\' && info->is_newline_accepted)) { info->newLine(); str++; diff --git a/src/ScriptParser.h b/src/ScriptParser.h index 8ba767b6..b0adc38a 100644 --- a/src/ScriptParser.h +++ b/src/ScriptParser.h @@ -102,9 +102,9 @@ class ScriptParser { #ifdef MACOSX void checkBundled(); bool isBundled() {return is_bundled; } - pstring bundleResPath() { return bundle_res_path; } - pstring bundleAppPath() { return bundle_app_path; } - pstring bundleAppName() { return bundle_app_name; } + const pstring& bundleResPath() { return bundle_res_path; } + const pstring& bundleAppPath() { return bundle_app_path; } + const pstring& bundleAppName() { return bundle_app_name; } #endif /* Command */