mirror of
https://github.com/joel16/CMFileManager-PSP.git
synced 2024-11-23 03:39:42 +00:00
Fix a few memory leaks and out of bounds buffer access
This commit is contained in:
parent
04d9792918
commit
707c30650e
@ -81,11 +81,13 @@ int Config_Load(void) {
|
||||
jsmn_init(&parser);
|
||||
if (R_FAILED(ret = jsmn_parse(&parser, buf, strlen(buf), token, 128))) {
|
||||
Log_Print("jsmn_parse failed in Config_Load %d\n", ret);
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret < 1 || token[0].type != JSMN_OBJECT) {
|
||||
Log_Print("jsmn_parse failed: object expected\n");
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ int Archive_ExtractArchive(const char *path) {
|
||||
char *dest_path = (char *)calloc(256, sizeof(char));
|
||||
char *dirname_without_ext = Archive_RemoveFileExt((char *)path);
|
||||
|
||||
snprintf(dest_path, 512, "%s/", dirname_without_ext);
|
||||
snprintf(dest_path, 256, "%s/", dirname_without_ext);
|
||||
FS_MakeDir(dest_path);
|
||||
|
||||
int count = 0;
|
||||
|
@ -50,8 +50,10 @@ static int FileOptions_CreateFolder(void) {
|
||||
char *buf = malloc(256);
|
||||
strcpy(buf, G2D_KeyboardGetText("Enter name", "New folder"));
|
||||
|
||||
if (strncmp(buf, "", 1) == 0)
|
||||
if (strncmp(buf, "", 1) == 0) {
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char path[512];
|
||||
strcpy(path, cwd);
|
||||
@ -70,8 +72,10 @@ static int FileOptions_CreateFile(void) {
|
||||
char *buf = malloc(256);
|
||||
strcpy(buf, G2D_KeyboardGetText("Enter name", "New file"));
|
||||
|
||||
if (strncmp(buf, "", 1) == 0)
|
||||
if (strncmp(buf, "", 1) == 0) {
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char path[512];
|
||||
strcpy(path, cwd);
|
||||
|
Loading…
Reference in New Issue
Block a user