mirror of
https://github.com/wiiu-env/PayloadLoaderPayload.git
synced 2024-09-29 01:28:43 +02: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.
|
// Somewhere in this loader is a memory leak.
|
||||||
// This is a hacky solution to free that memory.
|
// This is a hacky solution to free that memory.
|
||||||
uint32_t head_end = (uint32_t) malloc(1024);
|
uint32_t head_end = (uint32_t) malloc(1024);
|
||||||
MEMExpHeapBlock *curUsedBlock = (MEMExpHeapBlock *) (head_end - 0x14);
|
MEMExpHeapBlock *prevBlock, *curUsedBlock = (MEMExpHeapBlock *) (head_end - 0x14);
|
||||||
while (curUsedBlock != 0) {
|
while (curUsedBlock != 0) {
|
||||||
curUsedBlock = curUsedBlock->prev;
|
prevBlock = curUsedBlock->prev;
|
||||||
free(&curUsedBlock[1]);
|
free(&curUsedBlock[1]);
|
||||||
|
|
||||||
if(((uint32_t) &curUsedBlock[1]) == memory_start){
|
if(((uint32_t) &curUsedBlock[1]) == memory_start){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
curUsedBlock = prevBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = -1;
|
int res = -1;
|
||||||
@ -256,6 +257,7 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
|||||||
|
|
||||||
OSSleepTicks(OSMillisecondsToTicks(16));
|
OSSleepTicks(OSMillisecondsToTicks(16));
|
||||||
}
|
}
|
||||||
|
free(screenBuffer);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto const&[key, val] : payloads) {
|
for (auto const&[key, val] : payloads) {
|
||||||
if (i == selected) {
|
if (i == selected) {
|
||||||
@ -263,6 +265,5 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
free(screenBuffer);
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user