Skip to content

Commit

Permalink
(Coverity) Fix uninitialized variables; fix some resource leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed May 23, 2016
1 parent c72222b commit 0a32241
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
8 changes: 4 additions & 4 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,8 +1961,8 @@ bool config_load_override(void)
{
char buf[PATH_MAX_LENGTH];
char config_directory[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH] = {0};
char game_path[PATH_MAX_LENGTH] = {0};
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
Expand Down Expand Up @@ -2140,8 +2140,8 @@ bool config_load_override(void)
bool config_load_remap(void)
{
char remap_directory[PATH_MAX_LENGTH]; /* path to the directory containing retroarch.cfg (prefix) */
char core_path[PATH_MAX_LENGTH]; /* final path for core-specific configuration (prefix+suffix) */
char game_path[PATH_MAX_LENGTH]; /* final path for game-specific configuration (prefix+suffix) */
char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */
char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
Expand Down
2 changes: 1 addition & 1 deletion input/input_autodetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static bool input_autoconfigure_joypad_from_conf_dir(
autoconfig_params_t *params)
{
size_t i;
char path[PATH_MAX_LENGTH];
char path[PATH_MAX_LENGTH] = {0};
int ret = 0;
int index = -1;
int current_best = 0;
Expand Down
25 changes: 14 additions & 11 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size,

if (settings)
{
char core_path[PATH_MAX_LENGTH];
char display_name[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH] = {0};
char *last = NULL;

fill_pathname_join(
Expand Down Expand Up @@ -213,7 +213,7 @@ static void print_buf_lines_extended(file_list_t *list, char *buf, int buf_size,

if (settings)
{
char core_path[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH] = {0};
char display_name[PATH_MAX_LENGTH];
char *last = NULL;

Expand Down Expand Up @@ -1590,7 +1590,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
char path_playlist[PATH_MAX_LENGTH];
char path_base[PATH_MAX_LENGTH] = {0};
char query[PATH_MAX_LENGTH] = {0};
playlist_t *playlist = NULL;
playlist_t *playlist = NULL;
database_info_list_t *db_info = NULL;
menu_handle_t *menu = NULL;
settings_t *settings = config_get_ptr();
Expand Down Expand Up @@ -2164,7 +2164,8 @@ static int menu_displaylist_parse_horizontal_list(
{
menu_ctx_list_t list_info;
menu_ctx_list_t list_horiz_info;
char path_playlist[PATH_MAX_LENGTH], lpl_basename[PATH_MAX_LENGTH];
char lpl_basename[PATH_MAX_LENGTH];
char path_playlist[PATH_MAX_LENGTH] = {0};
bool is_historylist = false;
playlist_t *playlist = NULL;
menu_handle_t *menu = NULL;
Expand Down Expand Up @@ -3812,8 +3813,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
}
else
{
char path_playlist[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
char path_playlist[PATH_MAX_LENGTH] = {0};
playlist_t *playlist = NULL;

menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL);

Expand Down Expand Up @@ -3935,10 +3936,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
string_list_new_special(STRING_LIST_SUPPORTED_CORES_NAMES,
(void*)menu->deferred_path,
&cores_names_len, &cores_names_size);
struct string_list *cores_paths =
string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS,
(void*)menu->deferred_path,
&cores_paths_len, &cores_paths_size);

if (cores_names_size == 0)
{
Expand All @@ -3949,6 +3946,11 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
}
else
{
struct string_list *cores_paths =
string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS,
(void*)menu->deferred_path,
&cores_paths_len, &cores_paths_size);

for (i = 0; i < cores_names_size; i++)
{
switch (type)
Expand All @@ -3968,9 +3970,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
cores_names->elems[i].data);
}

string_list_free(cores_names);
string_list_free(cores_paths);
}

string_list_free(cores_names);
}
break;
case DISPLAYLIST_CORE_INFO:
Expand Down
5 changes: 3 additions & 2 deletions menu/menu_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ void menu_shader_manager_init(menu_handle_t *menu)
break;
default:
{
char preset_path[PATH_MAX_LENGTH];
const char *shader_dir = *settings->directory.video_shader ?
char preset_path[PATH_MAX_LENGTH] = {0};
const char *shader_dir =
*settings->directory.video_shader ?
settings->directory.video_shader : settings->directory.system;

fill_pathname_join(preset_path, shader_dir,
Expand Down
8 changes: 4 additions & 4 deletions tasks/task_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ static int file_decompressed_subdir(const char *name,
unsigned cmode, uint32_t csize,uint32_t size,
uint32_t crc32, void *userdata)
{
char path[PATH_MAX_LENGTH];
char path_dir[PATH_MAX_LENGTH];
decompress_state_t *dec = (decompress_state_t*)userdata;
char path[PATH_MAX_LENGTH] = {0};
decompress_state_t *dec = (decompress_state_t*)userdata;

/* Ignore directories. */
if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\')
Expand Down Expand Up @@ -98,8 +98,8 @@ static int file_decompressed(const char *name, const char *valid_exts,
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata)
{
char path[PATH_MAX_LENGTH];
decompress_state_t *dec = (decompress_state_t*)userdata;
char path[PATH_MAX_LENGTH] = {0};
decompress_state_t *dec = (decompress_state_t*)userdata;

/* Ignore directories. */
if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\')
Expand Down
2 changes: 1 addition & 1 deletion tasks/task_screenshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
static bool screenshot_dump(const char *folder, const void *frame,
unsigned width, unsigned height, int pitch, bool bgr24)
{
char shotname[256];
char filename[PATH_MAX_LENGTH];
char shotname[256] = {0};
bool ret = false;
settings_t *settings = config_get_ptr();
#if defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG)
Expand Down

0 comments on commit 0a32241

Please sign in to comment.