From 0bcfd5ca9205be8b7ebaf4bbb82ff1c00a35006e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Nov 2023 22:58:06 +0100 Subject: [PATCH] fixed potentially undefined behavior with bool parameters in direct native functions. --- source/common/scripting/interface/vmnatives.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index daed2f091..1289f3163 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -667,7 +667,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetBottomAlignOffset, GetBottomAlignOffset) ACTION_RETURN_FLOAT(GetBottomAlignOffset(self, code)); } -static int StringWidth(FFont *font, const FString &str, bool localize) +static int StringWidth(FFont *font, const FString &str, int localize) { const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); return font->StringWidth(txt); @@ -681,7 +681,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, StringWidth, StringWidth) ACTION_RETURN_INT(StringWidth(self, str, localize)); } -static int GetMaxAscender(FFont* font, const FString& str, bool localize) +static int GetMaxAscender(FFont* font, const FString& str, int localize) { const char* txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); return font->GetMaxAscender(txt); @@ -695,7 +695,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetMaxAscender, GetMaxAscender) ACTION_RETURN_INT(GetMaxAscender(self, str, localize)); } -static int CanPrint(FFont *font, const FString &str, bool localize) +static int CanPrint(FFont *font, const FString &str, int localize) { const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); return font->CanPrint(txt);