From f2333b6f26b1df18a8551b874fdb7e05263c51b2 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 3 Aug 2006 03:45:58 +0000 Subject: [PATCH] - Fixed: The ACS VM made no checks for object files without strings, assuming that if it didn't have any strings, then it didn't matter what it calculated for the location of the string table because it would never be referenced. While this is true for a script all by itself, it means a crash if you have a map script without strings that imports a library with strings and the library tries to use one of its strings. SVN r281 (trunk) --- docs/rh-log.txt | 8 ++++++++ src/p_acs.cpp | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bc5eafd8c4..f7bb2b44c4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +August 2, 2006 +- Fixed: The ACS VM made no checks for object files without strings, assuming + that if it didn't have any strings, then it didn't matter what it calculated + for the location of the string table because it would never be referenced. + While this is true for a script all by itself, it means a crash if you have + a map script without strings that imports a library with strings and the + library tries to use one of its strings. + August 1, 2006 - It turns out that the Visual C++ 2005 runtime calls IsDebuggerPresent, which is not available under Windows 95. Since this is (or at least should be) the diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 143c4caa06..19ca624c5f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -758,7 +758,15 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) else { UnencryptStrings (); - StringTable = FindChunk (MAKE_ID('S','T','R','L')) - Data + 8; + BYTE *strings = FindChunk (MAKE_ID('S','T','R','L')); + if (strings != NULL) + { + StringTable = strings - Data + 8; + } + else + { + StringTable = 0; + } } if (Format == ACS_Old) @@ -1388,6 +1396,10 @@ const char *FBehavior::StaticLookupString (DWORD index) const char *FBehavior::LookupString (DWORD index) const { + if (StringTable == 0) + { + return NULL; + } if (Format == ACS_Old) { DWORD *list = (DWORD *)(Data + StringTable);