From 2d0f6339f7f7dde2d74dc9dee0085a500774b02d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 28 Apr 2015 15:34:48 +0200 Subject: [PATCH] - fixed some memory leaks: The global symbol table and the argument list for DECORATE called action specials were never freed. --- src/d_main.cpp | 2 ++ src/dobjtype.cpp | 10 ++++++++++ src/dobjtype.h | 2 ++ src/thingdef/thingdef_states.cpp | 2 +- src/win32/i_main.cpp | 2 +- src/win32/i_rawps2.cpp | 4 ++++ src/win32/i_xinput.cpp | 4 ++++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 6ea7e8ff5..2d10fa3dd 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2261,6 +2261,8 @@ void D_DoomMain (void) do { + InitGlobalSymbols(); + if (restart) { C_InitConsole(SCREENWIDTH, SCREENHEIGHT, false); diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index f7623f84d..d930256f6 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -517,8 +517,18 @@ void PType::StaticInit() TypeTable.AddType(TypeState = new PStatePointer); TypeTable.AddType(TypeFixed = new PFixed); TypeTable.AddType(TypeAngle = new PAngle); +} +void ReleaseGlobalSymbols() +{ + GlobalSymbols.ReleaseSymbols(); +} + +void InitGlobalSymbols() +{ // Add types to the global symbol table. + atterm(ReleaseGlobalSymbols); + GlobalSymbols.ReleaseSymbols(); GlobalSymbols.AddSymbol(new PSymbolType(NAME_sByte, TypeSInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Byte, TypeUInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Short, TypeSInt16)); diff --git a/src/dobjtype.h b/src/dobjtype.h index 92917f7ec..ff34a4b8f 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -801,4 +801,6 @@ public: PSymbolConstString() {} }; +void InitGlobalSymbols(); + #endif diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index fedfd924e..4696b7e57 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -72,11 +72,11 @@ FxVMFunctionCall *DoActionSpecials(FScanner &sc, FState & state, Baggage &bag) int min_args, max_args; FString specname = sc.String; - FArgumentList *args = new FArgumentList; int special = P_FindLineSpecial(sc.String, &min_args, &max_args); if (special > 0 && min_args >= 0) { + FArgumentList *args = new FArgumentList; args->Push(new FxParameter(new FxConstant(special, sc))); i = 0; diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 668c74f95..1404fc465 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1279,7 +1279,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - //_crtBreakAlloc = 18800; + _crtBreakAlloc = 22884; #endif DoMain (hInstance); diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp index 84fb605c6..0ca314504 100644 --- a/src/win32/i_rawps2.cpp +++ b/src/win32/i_rawps2.cpp @@ -1293,6 +1293,10 @@ void I_StartupRawPS2() { JoyDevices[INPUT_RawPS2] = joys; } + else + { + delete joys; + } } } } diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index 5a02d7af4..cc1dce6ee 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -783,6 +783,10 @@ void I_StartupXInput() { JoyDevices[INPUT_XInput] = joys; } + else + { + delete joys; + } } } }