From f74380b3e9f6dcd32157ef13bfead8e84a3aea16 Mon Sep 17 00:00:00 2001 From: Fyren Date: Sun, 3 May 2009 11:23:12 -0700 Subject: [PATCH 1/6] Fix casting problems in TextParsers breaking TrimString for non-ASCII (bug 3800, r+a12=dvander) --- core/TextParsers.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/TextParsers.cpp b/core/TextParsers.cpp index 9cc6c231..87b68311 100644 --- a/core/TextParsers.cpp +++ b/core/TextParsers.cpp @@ -48,7 +48,7 @@ static int g_ws_chartable[255] = {0}; bool TextParsers::IsWhitespace(const char *stream) { - return g_ws_chartable[(unsigned)*stream] == 1; + return g_ws_chartable[(unsigned char)*stream] == 1; } TextParsers::TextParsers() @@ -508,7 +508,7 @@ SMCError TextParsers::ParseStream_SMC(void *stream, else { /* Check if we're whitespace or not */ - if (!g_ws_chartable[(unsigned)c]) + if (!g_ws_chartable[(unsigned char)c]) { bool restage = false; /* Check various special tokens: @@ -823,7 +823,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene ***************************************************/ /* First strip beginning whitespace */ - while (*ptr != '\0' && g_ws_chartable[(unsigned)*ptr] != 0) + while (*ptr != '\0' && g_ws_chartable[(unsigned char)*ptr] != 0) { ptr++; } @@ -876,7 +876,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene /* Lastly, strip ending whitespace off */ for (size_t i=len-1; i>=0 && i Date: Thu, 7 May 2009 20:15:32 -0700 Subject: [PATCH 2/6] Fix sdktools MSVC9 project file (and sm_slap) for EP1 games (bug 3768) --- extensions/sdktools/msvc9/sdktools.vcproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 5b982d28..699e6419 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -125,7 +125,7 @@ AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" @@ -369,7 +369,7 @@ AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -451,7 +451,7 @@ AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" From 7fd6b308f86446ac6f5e3a34463a169522ab9305 Mon Sep 17 00:00:00 2001 From: Fyren Date: Fri, 8 May 2009 00:10:12 -0700 Subject: [PATCH 3/6] Fix Windows L4D CreateFakeClient signature (bug 3792) --- gamedata/sdktools.games/engine.l4d.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamedata/sdktools.games/engine.l4d.txt b/gamedata/sdktools.games/engine.l4d.txt index 1f723871..1b0a0901 100644 --- a/gamedata/sdktools.games/engine.l4d.txt +++ b/gamedata/sdktools.games/engine.l4d.txt @@ -176,7 +176,7 @@ * the expected code. A pointer to sv (IServer interface) is used * here. */ - "CreateFakeClient_Windows" "\x55\x8B\xEC\x83\xEC\x08\x89\x4D\xF8\x8B\x45\x08\x50\xB9\x2A\x2A\x2A\x2A\xE8" + "CreateFakeClient_Windows" "\x8B\x44\x24\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8" } "Offsets" @@ -184,7 +184,7 @@ /* Offset into IVEngineServer::CreateFakeClient */ "sv" { - "windows" "14" + "windows" "6" } } From bf8c57c669a71077844c8885f47b861a0b9141b5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 9 May 2009 09:21:14 -0400 Subject: [PATCH 4/6] Fixed compiler choosing whether to emit stradjust.pri on dynamic arrays based on uninitialized memory (bug 3810, r=fyren,pred, a12=blocking). --- sourcepawn/compiler/sc1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index af7c1ef9..5df0aea5 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -2303,12 +2303,13 @@ static int declloc(int fstatic) if (matchtoken(']')) { idxtag[numdim] = 0; dim[numdim] = 0; - numdim++; + numdim++; continue; } dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { all_constant = 0; + dim[numdim] = 0; } else if (dim_ident == iCONSTEXPR) { dim[numdim] = dim_val.constval; /* :TODO: :URGENT: Make sure this still works */ @@ -2323,7 +2324,7 @@ static int declloc(int fstatic) error(29); /* invalid expression, assumed 0 */ } numdim++; - needtoken(']'); + needtoken(']'); } while (matchtoken('[')); if (all_constant) { /* Change the last dimension to be based on chars instead if we have a string */ @@ -2335,7 +2336,7 @@ static int declloc(int fstatic) ident = iARRAY; stgdel(_index, _code); } else { - if (tag == pc_tag_string && numdim && dim[numdim-1]) { + if (tag == pc_tag_string && numdim) { stradjust(sPRI); } pushreg(sPRI); From 211c5dcfcd376baf651ab4f135799fdfc5233e5a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 10 May 2009 11:01:19 -0400 Subject: [PATCH 5/6] Fixed compiler reading uninitialized strings while processing varargs (bug 3811, r=fyren,pred, a12=blocking). --- sourcepawn/compiler/sc3.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 6018082f..1b365730 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -2422,8 +2422,6 @@ static int nesting=0; if (!checktags_string(arg[argidx].tags, arg[argidx].numtags, &lval) && !checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag)) error(213); - if (lval.tag!=0) - append_constval(&taglst,arg[argidx].name,lval.tag,0); break; case iVARIABLE: if (lval.ident==iLABEL || lval.ident==iFUNCTN || lval.ident==iREFFUNC From bd97bdd3787be8b4d6d3eb96d1f69bcf6fdb3241 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 11 May 2009 11:32:59 +1200 Subject: [PATCH 6/6] Fixed unhook event crash (bug 3814, r=dvander) --- core/EventManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 04888f3b..a95e78c9 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -194,7 +194,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct } /* Cache the name for post hooks */ - pHook->name = strdup(name); + pHook->name = sm_strdup(name); /* Increase reference count */ pHook->refCount++; @@ -300,7 +300,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun sm_trie_delete(m_EventHooks, name); /* Free the cached name */ - free(pHook->name); + delete pHook->name; /* And finally free structure memory */ delete pHook; @@ -472,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast) assert(pHook->pPostHook == NULL); assert(pHook->pPreHook == NULL); sm_trie_delete(m_EventHooks, pHook->name); - free(pHook->name); + delete pHook->name; delete pHook; } }