diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 80b2ee34e3..d8d218a949 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -226,6 +226,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) error: if (jports != NULL) jack_free(jports); + free(jd); return NULL; } diff --git a/cheevos.c b/cheevos.c index b3dec0b1da..554d1e6f86 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1955,20 +1955,28 @@ static unsigned cheevos_find_game_id_nes( { 53, 198, 228 }; - bool round = true; - RFILE *file = filestream_open(info->path, RFILE_MODE_READ, 0); + bool round = true; + RFILE *file = NULL; uint8_t * data = (uint8_t *) malloc(rom_size << 14); - if (!file || !data) + if (!data) return 0; + file = filestream_open(info->path, RFILE_MODE_READ, 0); + + if (!file) + { + free(data); + filestream_close(file); + return 0; + } + /* from fceu core - need it for a correctly md5 sum */ memset(data, 0xFF, rom_size << 14); /* from fceu core - compute size using the cart mapper */ - mapper_no = (header.rom_type >> 4); + mapper_no = (header.rom_type >> 4); mapper_no |= (header.rom_type2 & 0xF0); - for (i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) { @@ -1977,7 +1985,8 @@ static unsigned cheevos_find_game_id_nes( * since PRGCartMapping wants ROM_size to be to the power of 2 * so instead if not to power of 2, we just use head.ROM_size when * we use FCEU_read. */ - if (not_power2[i] == mapper_no) { + if (not_power2[i] == mapper_no) + { round = false; break; } diff --git a/core_info.c b/core_info.c index 44930997c7..deb0d0362c 100644 --- a/core_info.c +++ b/core_info.c @@ -732,5 +732,7 @@ bool core_info_get_display_name(const char *path, char *s, size_t len) error: if (core_name) free(core_name); + if (display_name) + free(display_name); return false; } diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 1f517ae5fb..4c169c1721 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1050,6 +1050,8 @@ static bool frontend_linux_powerstate_check_acpi_sysfs( else *state = FRONTEND_POWERSTATE_ON_POWER_SOURCE; + retro_closedir(entry); + return true; error: diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 11c7b8035b..025b138dfe 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -618,11 +618,10 @@ static bool open_devices(udev_input_t *udev, const char *type, device_handle_cb { int fd = open(devnode, O_RDONLY | O_NONBLOCK); - (void)fd; - RARCH_LOG("[udev] Adding device %s as type %s.\n", devnode, type); if (!add_device(udev, devnode, cb)) RARCH_ERR("[udev] Failed to open device: %s (%s).\n", devnode, strerror(errno)); + close(fd); } udev_device_unref(dev); diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 97c8285ffc..ff7f851206 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -286,6 +286,8 @@ struct http_t *net_http_new(struct http_connection_t *conn) error: if (fd >= 0) socket_close(fd); + if (state) + free(state); return NULL; } diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index 9290a7b78c..2d31222a08 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -650,6 +650,8 @@ int rmsgpack_read(RFILE *fd, return read_map(fd, (uint32_t)tmp_len, callbacks, data); } + if (buff) + free(buff); return 0; error: diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 1ef5afb63c..a3ddeaebc6 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -226,7 +226,10 @@ bool cheat_manager_load(const char *path) cheat = cheat_manager_new(cheats); if (!cheat) + { + config_file_free(conf); return false; + } for (i = 0; i < cheats; i++) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index afa343df23..c941615d0e 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -180,6 +180,8 @@ static int deferred_push_cursor_manager_list_deferred( end: if (conf) config_file_free(conf); + free(rdb); + free(query); return ret; } diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 5175e44217..7bbeed3343 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -353,6 +353,9 @@ static int playlist_association_left(unsigned type, const char *label, strlcpy(settings->playlist_cores, new_playlist_cores, sizeof(settings->playlist_cores)); + string_list_free(stnames); + string_list_free(stcores); + return 0; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 2dbc0dd861..33d38209a5 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -375,6 +375,8 @@ static int playlist_association_right(unsigned type, const char *label, strlcpy(settings->playlist_cores, new_playlist_cores, sizeof(settings->playlist_cores)); + string_list_free(stnames); + string_list_free(stcores); return 0; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 01ac77fcc8..82cfc7bf2b 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -289,6 +289,8 @@ static int action_start_playlist_association(unsigned type, const char *label) strlcpy(settings->playlist_cores, new_playlist_cores, sizeof(settings->playlist_cores)); + string_list_free(stcores); + string_list_free(stnames); return 0; } diff --git a/tasks/task_content.c b/tasks/task_content.c index e92eca34d0..8c91663c8c 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -617,6 +617,7 @@ static int content_file_compressed_read( if (optional_filename && path_file_exists(optional_filename)) { *length = 0; + string_list_free(str_list); return 1; }