]> Chaos Git - console/XDS.git/commitdiff
Fix potential memory leaks
authorLioncash <mathew1800@gmail.com>
Sun, 6 Dec 2015 19:41:47 +0000 (14:41 -0500)
committerLioncash <mathew1800@gmail.com>
Sun, 6 Dec 2015 19:44:14 +0000 (14:44 -0500)
source/Bootloader.cpp
source/kernel/CodeSet.cpp
source/kernel/Swi.cpp
source/process9/fs.cpp

index cbdb9c72913961e39a8d2659c7dcd8282f2f15a5..857ee17a1ca7736cca5e557c8471dca508bebbed 100644 (file)
@@ -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);
index 06f13810b7d8bbea7db94cd0c00d2cc38ac5f671..ab4f2cbd3cf375c5f9181372be002af84cb162b0 100644 (file)
@@ -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;
        }
index 507de8d151fb2bca5c10690b61428dc0c6d18426..70ce7a8eb06f0c01a19530ecd9699cc79a41f69a 100644 (file)
@@ -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<KSynchronizationObject>(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<KSynchronizationObject>(handle);
index f23f449ca0935d5589869c4f528484f9dde5351f..612804c4f8df3c47170f5eeede98de5f7e1c7ff5 100644 (file)
@@ -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