From ee256dfe16dc31f07e39f8829900979630e24ee8 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Tue, 3 May 2016 19:19:48 -0400 Subject: [PATCH] Fixed bad memory management in reIterNext occasionally causing junk returns --- Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp | 5 ++++- Mod Sources/TSExtension/TSExtension/source/dllmain.cpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index 4c24ac8..69c71e6 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -485,5 +485,8 @@ const char* reIterNext(Linker::SimObject* obj, S32 argc, const char* argv[]) std::string currentResult = (*currentMatchIter).str(); ++currentMatchIter; - return currentResult.data(); + char* result = Con::getReturnBuffer(currentResult.size() + 1); + memcpy(result, currentResult.data(), currentResult.size() + 1); + + return result; } \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp index 5e79cc3..d638670 100644 --- a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp @@ -408,6 +408,7 @@ __declspec(naked) void updateMoveHook() // Init WSA WSADATA wsadata; WSAStartup(0x0202, &wsadata); + Con::addMethodS(NULL,"dumpHex",&conDumpHex,"dumpHex(addr,size,spaces)",4,5); Con::addMethodS(NULL,"dumpDec",&conDumpUInt,"dumpDec(addr)",2,3); Con::addMethodS(NULL,"dumpFloat",&conDumpFloat,"dumpFloat(addr)",2,3); @@ -482,7 +483,9 @@ __declspec(naked) void updateMoveHook() char dbclient[3]="\x90\x90"; char gboaonadd[8]="FF\x25\xAA\xAA\xAA\xAA"; //memPatch("42e05f", +#ifdef MECH_MOVE_CODE *((unsigned int*)(mechcode+1))=(unsigned int)&updatemovehookptr; +#endif *((unsigned int*)(dbpack+1))=(unsigned int)&DBpackData; *((unsigned int*)(dbunpack+1))=(unsigned int)&DBunpackData; *((unsigned int*)(gboaonadd+2))=(unsigned int)&gboaptr;