viewData wasn't being freed

This commit is contained in:
Naim2000 2024-03-01 18:07:58 -05:00
parent 289a1cee79
commit 53072c83fe
5 changed files with 36 additions and 37 deletions

View File

@ -4,52 +4,29 @@
#include "fileops.h"
#include "malloc.h"
static struct stat st;
bool FSOPFileExists(const char* file)
{
FILE* f;
f = fopen(file, "rb");
if (f)
{
fclose(f);
return true;
}
return false;
return !stat(file, &st) && !S_ISDIR(st.st_mode);
}
bool FSOPFolderExists(const char* path)
{
DIR* dir;
dir = opendir(path);
if (dir)
{
closedir(dir);
return true;
}
return false;
return !stat(path, &st) && S_ISDIR(st.st_mode);
}
size_t FSOPGetFileSizeBytes(const char* path)
{
FILE* f;
size_t size = 0;
if (stat(path, &st) < 0) return 0;
f = fopen(path, "rb");
if (!f)
return 0;
fseek(f, 0, SEEK_END);
size = ftell(f);
fclose(f);
return size;
return st.st_size;
}
void FSOPDeleteFile(const char* file)
{
if (!FSOPFileExists(file))
return;
remove(file);
if (FSOPFileExists(file))
remove(file);
}
void FSOPMakeFolder(const char* path)
@ -89,8 +66,11 @@ s32 FSOPReadOpenFileA(FILE* fp, void** buffer, u32 offset, u32 length)
return -1;
s32 ret = FSOPReadOpenFile(fp, *buffer, offset, length);
if (ret < 0)
if (ret <= 0)
{
free(*buffer);
*buffer = NULL;
}
return ret;
}

View File

@ -1,6 +1,7 @@
#ifndef __FILEOPS_H__
#define __FILEOPS_H__
#include <sys/stat.h>
#include <dirent.h>
#include <ogcsys.h>

View File

@ -158,6 +158,11 @@ void Sys_Shutdown(void)
void Sys_LoadMenu(void)
{
/* SYSCALL(exit) does all of this already */
exit(0);
/* Also the code gcc generated for this looks really painful */
#if 0
int HBC = 0;
char *sig = (char *)0x80001804;
if (sig[0] == 'S' &&
@ -179,6 +184,7 @@ void Sys_LoadMenu(void)
}
/* Return to the Wii system menu */
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
#endif
}
s32 Sys_GetCerts(signed_blob **certs, u32 *len)

View File

@ -1165,6 +1165,13 @@ s32 Wad_Uninstall(FILE *fp)
goto out;
}
if (!__Wad_VerifyHeader(header))
{
puts("Invalid WAD file?");
ret = ES_EINVAL;
goto out;
}
/* Get title ID */
ret = __Wad_GetTitleID(fp, header, &tid);
if (ret < 0) {
@ -1215,7 +1222,8 @@ s32 Wad_Uninstall(FILE *fp)
GetSysMenuRegion(NULL, &region);
if((tid == TITLE_ID(0x10008, 0x48414B00 | 'E') || tid == TITLE_ID(0x10008, 0x48414B00 | 'P') || tid == TITLE_ID(0x10008, 0x48414B00 | 'J') || tid == TITLE_ID(0x10008, 0x48414B00 | 'K')
|| (tid == TITLE_ID(0x10008, 0x48414C00 | 'E') || tid == TITLE_ID(0x10008, 0x48414C00 | 'P') || tid == TITLE_ID(0x10008, 0x48414C00 | 'J') || tid == TITLE_ID(0x10008, 0x48414C00 | 'K'))) && region == 0)
|| (tid == TITLE_ID(0x10008, 0x48414C00 | 'E') || tid == TITLE_ID(0x10008, 0x48414C00 | 'P') || tid == TITLE_ID(0x10008, 0x48414C00 | 'J') || tid == TITLE_ID(0x10008, 0x48414C00 | 'K')))
&& region == 0)
{
printf("\n Unknown SM region\n Please check the site for updates\n");
ret = -999;
@ -1257,9 +1265,9 @@ s32 Wad_Uninstall(FILE *fp)
printf(" ERROR! (ret = %d)\n", ret);
/* Delete tickets */
if (ret >= 0) {
else {
u32 cnt;
tikview view ATTRIBUTE_ALIGN(0x20) = {};
static tikview view ATTRIBUTE_ALIGN(0x20);
/* Delete all tickets */
for (cnt = 0; cnt < viewCnt; cnt++) {
@ -1282,6 +1290,7 @@ s32 Wad_Uninstall(FILE *fp)
else
printf(" OK!\n");
}
free(viewData);
printf("\t\t>> Deleting title contents...");
fflush(stdout);

View File

@ -3,6 +3,8 @@
* https://github.com/DacoTaco/priiloader/blob/master/tools/DacosLove/source/Input.cpp
*/
#include <stdlib.h>
#include <unistd.h>
#include <ogc/lwp.h>
#include <wiiuse/wpad.h>
@ -107,7 +109,7 @@ static void* WKBThread(__attribute__((unused)) void* arg)
usleep(WKB_THREAD_UDELAY);
}
for (int led = 3; led; led--) { USBKeyboard_SetLed(led, false); usleep(WKB_ANIMATION_UDELAY); }
// for (int led = 3; led; led--) { USBKeyboard_SetLed(led, false); usleep(WKB_ANIMATION_UDELAY); }
return NULL;
}
@ -118,6 +120,7 @@ void WKB_Initialize(void)
WKBThreadActive = true;
LWP_CreateThread(&WKBThreadHandle, WKBThread, NULL, NULL, WKB_THREAD_STACK, WKB_THREAD_PRIORITY);
atexit(WKB_Deinitialize);
}
void WKB_Deinitialize(void)