From f9b110bf1d183289f347803432820696fe8522a2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 6 Dec 2015 14:41:47 -0500 Subject: [PATCH] Fix potential memory leaks --- source/Bootloader.cpp | 1 + source/kernel/CodeSet.cpp | 2 +- source/kernel/Swi.cpp | 2 ++ source/process9/fs.cpp | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Bootloader.cpp b/source/Bootloader.cpp index cbdb9c7..857ee17 100644 --- a/source/Bootloader.cpp +++ b/source/Bootloader.cpp @@ -260,6 +260,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker XDSERROR("data data block allocation failed."); free(code); free(sec); + free(rodata); return NULL; } memset(data, 0, datasize); diff --git a/source/kernel/CodeSet.cpp b/source/kernel/CodeSet.cpp index 06f1381..ab4f2cb 100644 --- a/source/kernel/CodeSet.cpp +++ b/source/kernel/CodeSet.cpp @@ -237,7 +237,7 @@ bool KCodeSet::Patch() u8* data = new u8[sz]; fread(data, sz, 1, f); LoadElfFile(data); - delete data; + delete[] data; fclose(f); return true; } diff --git a/source/kernel/Swi.cpp b/source/kernel/Swi.cpp index 507de8d..70ce7a8 100644 --- a/source/kernel/Swi.cpp +++ b/source/kernel/Swi.cpp @@ -647,6 +647,7 @@ void ProcessSwi(u8 swi, u32 Reg[15], KThread * currentThread) #ifdef SWILOG LOG("Process %s thread %u WaitSynchronizationN (%08x %08x %08x | %08x %08x) stub + not 100 correct", currentThread->m_owner->GetName(), currentThread->m_thread_id, pointer, handleCount, waitall, Reg[0], Reg[1]); #endif + delete list; return; } KSynchronizationObject* th = (KSynchronizationObject*)*currentThread->m_owner->GetHandleTable()->GetHandle(handle); @@ -1387,6 +1388,7 @@ void ProcessSwi(u8 swi, u32 Reg[15], KThread * currentThread) #ifdef SWILOG LOG("Process %s thread %u ReplyAndReceive (%08x %08x %08x | %08x %08x) stub + not 100 correct", currentThread->m_owner->GetName(), currentThread->m_thread_id, pointer, handleCount, replyTarget, Reg[0], Reg[1]); #endif + delete list; return; } KSynchronizationObject* th = (KSynchronizationObject*)*currentThread->m_owner->GetHandleTable()->GetHandle(handle); diff --git a/source/process9/fs.cpp b/source/process9/fs.cpp index f23f449..612804c 100644 --- a/source/process9/fs.cpp +++ b/source/process9/fs.cpp @@ -460,7 +460,7 @@ void P9FS::Command(u32 data[], u32 numb) resdata[0] = 0x00130040; resdata[1] = 0x00000000; resdata[2] = 0x00000000; //u8 - delete str; + delete[] str; break; } case 0x16: //CloseArchive -- 2.39.5