diff --git a/file.c b/file.c index 9213871697..63fd323c95 100644 --- a/file.c +++ b/file.c @@ -288,6 +288,7 @@ bool load_state(const char *path) for (i = 0; i < num_blocks; i++) free(blocks[i].data); free(blocks); + free(buf); return ret; } diff --git a/frontend/menu/disp/lakka.c b/frontend/menu/disp/lakka.c index a50bba2bd9..0d11c521d5 100644 --- a/frontend/menu/disp/lakka.c +++ b/frontend/menu/disp/lakka.c @@ -1118,31 +1118,28 @@ static void *lakka_init(void) } menu = (menu_handle_t*)calloc(1, sizeof(*menu)); - if (!menu) return NULL; + menu->userdata = (lakka_handle_t*)calloc(1, sizeof(lakka_handle_t)); + if (!menu->userdata) + { + free(menu); + return NULL; + } lakka_init_core_info(menu); - menu->userdata = (lakka_handle_t*)calloc(1, sizeof(lakka_handle_t)); - - if (!menu->userdata) - return NULL; - lakka = (lakka_handle_t*)menu->userdata; - - if (!lakka) - return NULL; - lakka->num_categories = g_extern.core_info ? (g_extern.core_info->count + 1) : 1; - lakka->categories = (menu_category_t*) calloc(lakka->num_categories, sizeof(menu_category_t)); if (!lakka->categories) { + free(menu->userdata); free(menu); + return NULL; } diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index a055872540..2c96db65b2 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -408,17 +408,19 @@ static void *rgui_init(void) menu->userdata = (rgui_handle_t*)calloc(1, sizeof(rgui_handle_t)); if (!menu->userdata) + { + free(menu); return NULL; - - rgui_handle_t *rgui = (rgui_handle_t*)menu->userdata; - - if (!rgui) - return NULL; - + } + menu->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); if (!menu->frame_buf) + { + free(menu->userdata); + free(menu); return NULL; + } menu->width = 320; menu->height = 240; @@ -431,6 +433,9 @@ static void *rgui_init(void) RARCH_ERR("No font bitmap or binary, abort"); rarch_main_command(RARCH_CMD_QUIT_RETROARCH); + + free(menu->userdata); + free(menu); return NULL; } diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index 562a04d793..a1314bd497 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -308,7 +308,10 @@ static void *rmenu_init(void) menu_texture = (struct texture_image*)calloc(1, sizeof(*menu_texture)); if (!menu_texture) + { + free(menu); return NULL; + } return menu; } diff --git a/frontend/menu/disp/xmb.c b/frontend/menu/disp/xmb.c index 3fd0334f89..b6e047c6e6 100644 --- a/frontend/menu/disp/xmb.c +++ b/frontend/menu/disp/xmb.c @@ -575,13 +575,13 @@ static void *xmb_init(void) menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t)); if (!menu->userdata) + { + free(menu); return NULL; + } xmb = (xmb_handle_t*)menu->userdata; - if (!xmb) - return NULL; - xmb->x = 0; xmb->alpha = 1.0f; xmb->depth = 1; diff --git a/frontend/menu/menu_animation.c b/frontend/menu/menu_animation.c index bc793b0530..77231c9e27 100644 --- a/frontend/menu/menu_animation.c +++ b/frontend/menu/menu_animation.c @@ -31,10 +31,14 @@ void add_tween(float duration, float target_value, float* subject, easingFunc easing, tweenCallback callback) { tween_t *tween = NULL; - tweens = (tween_t*) + tween_t *temp_tweens = (tween_t*) realloc(tweens, (numtweens + 1) * sizeof(tween_t)); - if (!tweens) /* Realloc failed. */ + if (temp_tweens) + { + tweens = temp_tweens; + } + else /* Realloc failed. */ { tween_free(tweens); return; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index b163361d0b..f47c764614 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -67,10 +67,8 @@ static void menu_environment_get(int *argc, char *argv[], if (!g_extern.has_set_verbosity) wrap_args->verbose = g_extern.verbosity; wrap_args->config_path = *g_extern.config_path ? g_extern.config_path : NULL; - if (!g_extern.has_set_save_path) - wrap_args->sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL; - if (!g_extern.has_set_state_path) - wrap_args->state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL; + wrap_args->sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL; + wrap_args->state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL; wrap_args->content_path = *g_extern.fullpath ? g_extern.fullpath : NULL; if (!g_extern.has_set_libretro) wrap_args->libretro_path = *g_settings.libretro ? g_settings.libretro : NULL; diff --git a/general.c b/general.c index 191567841e..c4783548f8 100644 --- a/general.c +++ b/general.c @@ -51,6 +51,9 @@ void rarch_playlist_load_content(content_playlist_t *playlist, index, &path, &core_path, NULL); strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro)); + + driver.menu->load_no_content = (path) ? false : true; + rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); rarch_main_command(RARCH_CMD_LOAD_CORE); diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 7315339f0d..f4bc3da15d 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -60,9 +60,15 @@ static void* hidpad_ps3_connect(void *connect_data, uint32_t slot, send_control_ struct hidpad_ps3_data* device = (struct hidpad_ps3_data*) calloc(1, sizeof(struct hidpad_ps3_data)); - if (!device || !connection) + if (!device) return NULL; + if (!connection) + { + free(device); + return NULL; + } + device->connection = connection; device->slot = slot; device->send_control = ptr; diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 2ab3dedf2d..1c3ff2b382 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -54,9 +54,15 @@ static void* hidpad_ps4_connect(void *connect_data, uint32_t slot, send_control_ struct hidpad_ps4_data* device = (struct hidpad_ps4_data*) calloc(1, sizeof(struct hidpad_ps4_data)); - if (!device || !connection) + if (!device) return NULL; + if (!connection) + { + free(device); + return NULL; + } + device->connection = connection; device->slot = slot; device->send_control = ptr; diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index 6d9f108ca2..2aea8d2445 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -463,9 +463,15 @@ static void* hidpad_wii_connect(void *data, uint32_t slot, struct wiimote_t *device = (struct wiimote_t*) calloc(1, sizeof(struct wiimote_t)); - if (!device || !connection) + if (!device) return NULL; + if (!connection) + { + free(device); + return NULL; + } + device->connection = connection; device->unid = slot; device->state = WIIMOTE_STATE_CONNECTED; diff --git a/settings_data.c b/settings_data.c index 71dc286908..7554f747a1 100644 --- a/settings_data.c +++ b/settings_data.c @@ -4276,16 +4276,6 @@ bool setting_data_append_list_path_options( SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); #endif - CONFIG_PATH( - g_settings.libretro, - "libretro_path", - "Libretro Path", - "", - group_info.name, - subgroup_info.name, - general_write_handler, - general_read_handler) ; - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_DIR( g_settings.libretro_directory,