From e939d6885d293020469840eef43a0ad42f902a8e Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 5 Sep 2015 23:58:02 +0200 Subject: [PATCH] - Fixed a crash in ACS strlen parsing with invalid argument. --- src/p_acs.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index b703b87dd..54f9fa658 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8880,7 +8880,22 @@ scriptwait: break; case PCD_STRLEN: - STACK(1) = SDWORD(strlen(FBehavior::StaticLookupString (STACK(1)))); + { + const char *str = FBehavior::StaticLookupString(STACK(1)); + if (str != NULL) + { + STACK(1) = SDWORD(strlen(str)); + break; + } + + static bool StrlenInvalidPrintedAlready = false; + if (!StrlenInvalidPrintedAlready) + { + Printf(PRINT_BOLD, "Warning: ACS function strlen called with invalid string argument.\n"); + StrlenInvalidPrintedAlready = true; + } + STACK(1) = 0; + } break; case PCD_GETCVAR: