mirror of
https://github.com/wiiu-env/PayloadLoaderPayload.git
synced 2024-11-16 06:49:19 +01:00
Update main.cpp
Memory fixes, head_end doesnt get freed and you shouldnt use ->prev pointer after its freed. Also memory leak when payload is selected.
This commit is contained in:
parent
6098af25eb
commit
5074c962aa
@ -95,14 +95,15 @@ extern "C" int _start(int argc, char **argv) {
|
||||
// Somewhere in this loader is a memory leak.
|
||||
// This is a hacky solution to free that memory.
|
||||
uint32_t head_end = (uint32_t) malloc(1024);
|
||||
MEMExpHeapBlock *curUsedBlock = (MEMExpHeapBlock *) (head_end - 0x14);
|
||||
MEMExpHeapBlock *prevBlock, *curUsedBlock = (MEMExpHeapBlock *) (head_end - 0x14);
|
||||
while (curUsedBlock != 0) {
|
||||
curUsedBlock = curUsedBlock->prev;
|
||||
prevBlock = curUsedBlock->prev;
|
||||
free(&curUsedBlock[1]);
|
||||
|
||||
if(((uint32_t) &curUsedBlock[1]) == memory_start){
|
||||
break;
|
||||
}
|
||||
curUsedBlock = prevBlock;
|
||||
}
|
||||
|
||||
int res = -1;
|
||||
@ -256,6 +257,7 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
||||
|
||||
OSSleepTicks(OSMillisecondsToTicks(16));
|
||||
}
|
||||
free(screenBuffer);
|
||||
int i = 0;
|
||||
for (auto const&[key, val] : payloads) {
|
||||
if (i == selected) {
|
||||
@ -263,6 +265,5 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
||||
}
|
||||
i++;
|
||||
}
|
||||
free(screenBuffer);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user