From 653e8ff6fe4a077bb01d451daaa279e37f8f1a0c Mon Sep 17 00:00:00 2001 From: din Date: Thu, 14 May 2020 16:19:23 -0500 Subject: [PATCH] Small memory fixes. --- src/RageSurface_Load_PNG.cpp | 6 +++++- src/arch/InputHandler/LinuxInputManager.cpp | 2 ++ src/archutils/Unix/SignalHandler.cpp | 9 +++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/RageSurface_Load_PNG.cpp b/src/RageSurface_Load_PNG.cpp index 17d0de9390..4549eccfb8 100644 --- a/src/RageSurface_Load_PNG.cpp +++ b/src/RageSurface_Load_PNG.cpp @@ -123,7 +123,6 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro CHECKPOINT_M("Header only png about to be processed."); img = CreateSurfaceFrom( width, height, 32, 0, 0, 0, 0, nullptr, width*4 ); png_destroy_read_struct( &png, &info_ptr, nullptr ); - return img; } @@ -255,6 +254,11 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro png_read_end( png, info_ptr ); png_destroy_read_struct( &png, &info_ptr, nullptr ); + if(row_pointers != nullptr) + { + delete[] row_pointers; + } + return img; } diff --git a/src/arch/InputHandler/LinuxInputManager.cpp b/src/arch/InputHandler/LinuxInputManager.cpp index 2981eccd53..3961687100 100644 --- a/src/arch/InputHandler/LinuxInputManager.cpp +++ b/src/arch/InputHandler/LinuxInputManager.cpp @@ -80,6 +80,8 @@ LinuxInputManager::LinuxInputManager() // Sort devices for more consistent numbering. std::sort(m_vsPendingEventDevices.begin(), m_vsPendingEventDevices.end(), cmpDevices); std::sort(m_vsPendingJoystickDevices.begin(), m_vsPendingJoystickDevices.end(), cmpDevices); + + closedir(sysClassInput); } void LinuxInputManager::InitDriver(InputHandler_Linux_Event* driver) diff --git a/src/archutils/Unix/SignalHandler.cpp b/src/archutils/Unix/SignalHandler.cpp index e049cbb849..5ec0ee8ea6 100644 --- a/src/archutils/Unix/SignalHandler.cpp +++ b/src/archutils/Unix/SignalHandler.cpp @@ -3,6 +3,7 @@ #include "RageLog.h" #include "SignalHandler.h" #include "GetSysInfo.h" +#include #if defined(HAVE_LIBPTHREAD) #include "archutils/Common/PthreadHelpers.h" @@ -31,7 +32,7 @@ static int find_stack_direction2( char *p ) NOINLINE; static int find_stack_direction() NOINLINE; static vector handlers; -SaveSignals *saved_sigs; +unique_ptr saved_sigs; static int signals[] = { @@ -143,10 +144,10 @@ static void *CreateStack( int size ) /* Hook up events to fatal signals, so we can clean up if we're killed. */ void SignalHandler::OnClose( handler h ) { - if( saved_sigs == nullptr ) + //if the unique_ptr has not been set, then enter. + if( !saved_sigs ) { - saved_sigs = new SaveSignals; - + saved_sigs.reset(new SaveSignals()); bool bUseAltSigStack = true; #if defined(LINUX)