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);
|
filestream_seek(file, sizeof(header), SEEK_CUR);
|
||||||
|
|
||||||
bytes = (round) ? rom_size : header.rom_size;
|
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);
|
filestream_close(file);
|
||||||
|
|
||||||
if (num_read <= 0)
|
if (num_read <= 0)
|
||||||
return 0;
|
{
|
||||||
|
free(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
MD5_Update(&ctx, (void*) data, rom_size << 14);
|
MD5_Update(&ctx, (void*) data, rom_size << 14);
|
||||||
MD5_Final(hash, &ctx);
|
MD5_Final(hash, &ctx);
|
||||||
|
|
|
@ -942,6 +942,8 @@ static void *gl_glsl_init(void *data, const char *path)
|
||||||
error:
|
error:
|
||||||
gl_glsl_destroy_resources(glsl);
|
gl_glsl_destroy_resources(glsl);
|
||||||
|
|
||||||
|
if (conf)
|
||||||
|
config_file_free(conf);
|
||||||
if (glsl)
|
if (glsl)
|
||||||
free(glsl);
|
free(glsl);
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,7 @@ py_state_t *py_state_new(const char *script,
|
||||||
if (!ret || len < 0)
|
if (!ret || len < 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Python: Failed to read script\n");
|
RARCH_ERR("Python: Failed to read script\n");
|
||||||
|
free(script_);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -786,7 +786,10 @@ static struct rpng_process *rpng_process_init(rpng_t *rpng, unsigned *width, uns
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!process->stream_backend->stream_decompress_init(process->stream))
|
if (!process->stream_backend->stream_decompress_init(process->stream))
|
||||||
|
{
|
||||||
|
free(process);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
inflate_buf = (uint8_t*)malloc(process->inflate_buf_size);
|
inflate_buf = (uint8_t*)malloc(process->inflate_buf_size);
|
||||||
if (!inflate_buf)
|
if (!inflate_buf)
|
||||||
|
|
|
@ -565,6 +565,7 @@ clean:
|
||||||
free(buff);
|
free(buff);
|
||||||
if (cur.is_valid)
|
if (cur.is_valid)
|
||||||
libretrodb_cursor_close(&cur);
|
libretrodb_cursor_close(&cur);
|
||||||
|
bintree_free(tree);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,15 +221,12 @@ bool cheat_manager_load(const char *path)
|
||||||
config_get_uint(conf, "cheats", &cheats);
|
config_get_uint(conf, "cheats", &cheats);
|
||||||
|
|
||||||
if (cheats == 0)
|
if (cheats == 0)
|
||||||
return false;
|
goto error;
|
||||||
|
|
||||||
cheat = cheat_manager_new(cheats);
|
cheat = cheat_manager_new(cheats);
|
||||||
|
|
||||||
if (!cheat)
|
if (!cheat)
|
||||||
{
|
goto error;
|
||||||
config_file_free(conf);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < cheats; i++)
|
for (i = 0; i < cheats; i++)
|
||||||
{
|
{
|
||||||
|
@ -263,6 +260,10 @@ bool cheat_manager_load(const char *path)
|
||||||
cheat_manager_state = cheat;
|
cheat_manager_state = cheat;
|
||||||
|
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
if (!path_file_exists(patch_path))
|
if (!path_file_exists(patch_path))
|
||||||
|
{
|
||||||
|
free(patch_data);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
RARCH_LOG("Found %s file in \"%s\", attempting to patch ...\n",
|
RARCH_LOG("Found %s file in \"%s\", attempting to patch ...\n",
|
||||||
patch_desc, patch_path);
|
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)
|
while (strncmp(tmp_token, token, tmp_len) != 0)
|
||||||
{
|
{
|
||||||
if (get_token(fd, tmp_token, tmp_len) <= 0)
|
if (get_token(fd, tmp_token, tmp_len) <= 0)
|
||||||
|
{
|
||||||
|
free(tmp_token);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmp_token);
|
free(tmp_token);
|
||||||
|
@ -180,7 +183,10 @@ static int detect_ps1_game_sub(const char *track_path,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!strncasecmp((const char*)(tmp + 33), "SYSTEM.CNF;1", 12))
|
if (!strncasecmp((const char*)(tmp + 33), "SYSTEM.CNF;1", 12))
|
||||||
|
{
|
||||||
|
filestream_close(fp);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tmp += *tmp;
|
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)
|
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
||||||
|
filestream_close(fd);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,5 +206,6 @@ error:
|
||||||
RARCH_ERR("%s \"%s\".\n",
|
RARCH_ERR("%s \"%s\".\n",
|
||||||
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
|
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
|
||||||
path);
|
path);
|
||||||
|
free(buf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue