(MSVC) Some more static code analysis warning fixes

This commit is contained in:
twinaphex 2019-01-10 22:49:23 +01:00
parent e4f9aebbd3
commit 3ac631c7a3
6 changed files with 26 additions and 6 deletions

View File

@ -4752,7 +4752,7 @@ bool config_save_overrides(int override_type)
/* Replaces currently loaded configuration file with /* Replaces currently loaded configuration file with
* another one. Will load a dummy core to flush state * another one. Will load a dummy core to flush state
* properly. */ * properly. */
bool config_replace(bool config_save_on_exit, char *path) bool config_replace(bool config_replace_save_on_exit, char *path)
{ {
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};
@ -4764,7 +4764,7 @@ bool config_replace(bool config_save_on_exit, char *path)
if (string_is_equal(path, path_get(RARCH_PATH_CONFIG))) if (string_is_equal(path, path_get(RARCH_PATH_CONFIG)))
return false; return false;
if (config_save_on_exit && !path_is_empty(RARCH_PATH_CONFIG)) if (config_replace_save_on_exit && !path_is_empty(RARCH_PATH_CONFIG))
config_save_file(path_get(RARCH_PATH_CONFIG)); config_save_file(path_get(RARCH_PATH_CONFIG));
path_set(RARCH_PATH_CONFIG, path); path_set(RARCH_PATH_CONFIG, path);

4
dirs.c
View File

@ -288,6 +288,10 @@ void dir_set(enum rarch_dir_type type, const char *path)
static void check_defaults_dir_create_dir(const char *path) static void check_defaults_dir_create_dir(const char *path)
{ {
char *new_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *new_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
if (!new_path)
return;
new_path[0] = '\0'; new_path[0] = '\0';
fill_pathname_expand_special(new_path, fill_pathname_expand_special(new_path,
path, path,

View File

@ -444,6 +444,10 @@ bool video_shader_resolve_current_parameters(config_file_t *conf,
return false; return false;
parameters = (char*)malloc(param_size); parameters = (char*)malloc(param_size);
if (!parameters)
return false;
parameters[0] = '\0'; parameters[0] = '\0';
/* Read in parameters which override the defaults. */ /* Read in parameters which override the defaults. */
@ -1328,6 +1332,9 @@ void video_shader_resolve_relative(struct video_shader *shader,
size_t tmp_path_size = 4096 * sizeof(char); size_t tmp_path_size = 4096 * sizeof(char);
char *tmp_path = (char*)malloc(tmp_path_size); char *tmp_path = (char*)malloc(tmp_path_size);
if (!tmp_path)
return;
tmp_path[0] = '\0'; tmp_path[0] = '\0';
for (i = 0; i < shader->passes; i++) for (i = 0; i < shader->passes; i++)

View File

@ -53,11 +53,15 @@ bool settings_list_append(rarch_setting_t **list,
if (list_info->index == list_info->size) if (list_info->index == list_info->size)
{ {
rarch_setting_t *list_settings = NULL;
list_info->size *= 2; list_info->size *= 2;
*list = (rarch_setting_t*) list_settings = (rarch_setting_t*)
realloc(*list, sizeof(rarch_setting_t) * list_info->size); realloc(*list, sizeof(rarch_setting_t) * list_info->size);
if (!*list)
if (!list_settings)
return false; return false;
*list = list_settings;
} }
return true; return true;

View File

@ -66,11 +66,12 @@ static void task_powerstate_handler(retro_task_t *task)
void task_push_get_powerstate(void) void task_push_get_powerstate(void)
{ {
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
powerstate_t *state = (powerstate_t*)calloc(1, sizeof(*state)); powerstate_t *state = NULL;
if (!task) if (!task)
return; return;
state = (powerstate_t*)calloc(1, sizeof(*state));
if (!state) if (!state)
{ {
free(task); free(task);

View File

@ -762,6 +762,10 @@ static void task_load_handler_finished(retro_task_t *task,
task_set_error(task, strdup("Task canceled")); task_set_error(task, strdup("Task canceled"));
task_data = (load_task_data_t*)calloc(1, sizeof(*task_data)); task_data = (load_task_data_t*)calloc(1, sizeof(*task_data));
if (!task_data)
return;
memcpy(task_data, state, sizeof(*task_data)); memcpy(task_data, state, sizeof(*task_data));
task_set_data(task, task_data); task_set_data(task, task_data);