mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-03-02 16:46:19 +00:00
Fix resource leaks (pointed out by Coverity)
This commit is contained in:
parent
4e07d14488
commit
42971febba
@ -1999,11 +1999,14 @@ static unsigned cheevos_find_game_id_nes(
|
||||
filestream_seek(file, sizeof(header), SEEK_CUR);
|
||||
|
||||
bytes = (round) ? rom_size : header.rom_size;
|
||||
num_read = filestream_read(file, (void*) data, 0x4000 * bytes );
|
||||
num_read = filestream_read(file, (void*)data, 0x4000 * bytes );
|
||||
filestream_close(file);
|
||||
|
||||
if (num_read <= 0)
|
||||
return 0;
|
||||
{
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MD5_Update(&ctx, (void*) data, rom_size << 14);
|
||||
MD5_Final(hash, &ctx);
|
||||
|
@ -942,6 +942,8 @@ static void *gl_glsl_init(void *data, const char *path)
|
||||
error:
|
||||
gl_glsl_destroy_resources(glsl);
|
||||
|
||||
if (conf)
|
||||
config_file_free(conf);
|
||||
if (glsl)
|
||||
free(glsl);
|
||||
|
||||
|
@ -310,6 +310,7 @@ py_state_t *py_state_new(const char *script,
|
||||
if (!ret || len < 0)
|
||||
{
|
||||
RARCH_ERR("Python: Failed to read script\n");
|
||||
free(script_);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,10 @@ static struct rpng_process *rpng_process_init(rpng_t *rpng, unsigned *width, uns
|
||||
return NULL;
|
||||
|
||||
if (!process->stream_backend->stream_decompress_init(process->stream))
|
||||
{
|
||||
free(process);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inflate_buf = (uint8_t*)malloc(process->inflate_buf_size);
|
||||
if (!inflate_buf)
|
||||
|
@ -565,6 +565,7 @@ clean:
|
||||
free(buff);
|
||||
if (cur.is_valid)
|
||||
libretrodb_cursor_close(&cur);
|
||||
bintree_free(tree);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -221,15 +221,12 @@ bool cheat_manager_load(const char *path)
|
||||
config_get_uint(conf, "cheats", &cheats);
|
||||
|
||||
if (cheats == 0)
|
||||
return false;
|
||||
goto error;
|
||||
|
||||
cheat = cheat_manager_new(cheats);
|
||||
|
||||
if (!cheat)
|
||||
{
|
||||
config_file_free(conf);
|
||||
return false;
|
||||
}
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < cheats; i++)
|
||||
{
|
||||
@ -263,6 +260,10 @@ bool cheat_manager_load(const char *path)
|
||||
cheat_manager_state = cheat;
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
config_file_free(conf);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
3
patch.c
3
patch.c
@ -523,7 +523,10 @@ static bool apply_patch_content(uint8_t **buf,
|
||||
return false;
|
||||
|
||||
if (!path_file_exists(patch_path))
|
||||
{
|
||||
free(patch_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
RARCH_LOG("Found %s file in \"%s\", attempting to patch ...\n",
|
||||
patch_desc, patch_path);
|
||||
|
@ -128,7 +128,10 @@ static int find_token(RFILE *fd, const char *token)
|
||||
while (strncmp(tmp_token, token, tmp_len) != 0)
|
||||
{
|
||||
if (get_token(fd, tmp_token, tmp_len) <= 0)
|
||||
{
|
||||
free(tmp_token);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
free(tmp_token);
|
||||
@ -180,7 +183,10 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||
return 0;
|
||||
|
||||
if (!strncasecmp((const char*)(tmp + 33), "SYSTEM.CNF;1", 12))
|
||||
{
|
||||
filestream_close(fp);
|
||||
break;
|
||||
}
|
||||
|
||||
tmp += *tmp;
|
||||
}
|
||||
@ -389,6 +395,7 @@ int find_first_data_track(const char *cue_path,
|
||||
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
||||
{
|
||||
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
||||
filestream_close(fd);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
|
@ -206,5 +206,6 @@ error:
|
||||
RARCH_ERR("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
|
||||
path);
|
||||
free(buf);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user