diff --git a/runloop_data.c b/runloop_data.c index adac44f6d7..84072b269c 100644 --- a/runloop_data.c +++ b/runloop_data.c @@ -131,28 +131,27 @@ static void data_runloop_iterate(bool is_thread) bool rarch_main_data_active(void) { - bool active = false; #ifdef HAVE_LIBRETRODB if (rarch_main_data_db_is_active()) - active = true; + return true; #endif #ifdef HAVE_OVERLAY if (input_overlay_data_is_active()) - active = true; + return true; #endif if (rarch_main_data_nbio_image_get_handle()) - active = true; + return true; if (rarch_main_data_nbio_get_handle()) - active = true; + return true; #ifdef HAVE_NETWORKING if (rarch_main_data_http_get_handle()) - active = true; + return true; if (rarch_main_data_http_conn_get_handle()) - active = true; + return true; #endif - return active; + return false; } #ifdef HAVE_THREADS diff --git a/tasks/task_database.c b/tasks/task_database.c index 11332bb64d..d9edcdcac1 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -362,8 +362,8 @@ static int database_info_iterate(database_state_handle_t *state, database_info_h static int database_info_poll(db_handle_t *db) { + char elem0[PATH_MAX_LENGTH]; uint32_t cb_type_hash = 0; - char elem0[PATH_MAX_LENGTH] = {0}; struct string_list *str_list = NULL; const char *path = msg_queue_pull(db->msg_queue); @@ -374,9 +374,10 @@ static int database_info_poll(db_handle_t *db) if (!str_list) goto error; + if (str_list->size < 1) + goto error; - if (str_list->size > 0) - strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); + strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); if (str_list->size > 1) cb_type_hash = msg_hash_calculate(str_list->elems[1].data); diff --git a/tasks/task_http.c b/tasks/task_http.c index 125275c6fd..5e9ecd6668 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -375,10 +375,11 @@ static int rarch_main_data_http_iterate_poll(http_handle_t *http) str_list = string_split(url, "|"); if (!str_list) - return -1; + goto error; + if (str_list->size < 1) + goto error; - if (str_list->size > 0) - strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); + strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); http->connection.handle = net_http_connection_new(elem0); @@ -398,6 +399,11 @@ static int rarch_main_data_http_iterate_poll(http_handle_t *http) string_list_free(str_list); return 0; + +error: + if (str_list) + string_list_free(str_list); + return -1; } /**