diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index 2d696d4157..15be2a3e16 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -330,13 +330,16 @@ bool rarch_task_push_image_load(const char *fullpath, const char *type, rarch_ta } nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio)); + + if (!nbio) + return false; + nbio->handle = handle; nbio->is_finished = false; nbio->cb = &cb_nbio_default; nbio->status = NBIO_STATUS_TRANSFER; nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER; - if (cb_type_hash == CB_MENU_WALLPAPER) nbio->cb = &cb_nbio_image_menu_wallpaper; else if (cb_type_hash == CB_MENU_BOXART) @@ -345,6 +348,13 @@ bool rarch_task_push_image_load(const char *fullpath, const char *type, rarch_ta nbio_begin_read(handle); t = (rarch_task_t*)calloc(1, sizeof(*t)); + + if (!t) + { + free(nbio); + return false; + } + t->state = nbio; t->handler = rarch_task_file_load_handler; t->callback = cb; diff --git a/tasks/task_http.c b/tasks/task_http.c index 01dfdfee8c..f115869a2a 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -227,6 +227,10 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task return false; http = (http_handle_t*)calloc(1, sizeof(*http)); + + if (!http) + return false; + http->connection.handle = conn; http->connection.cb = &cb_http_conn_default; @@ -235,15 +239,22 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task http->status = HTTP_STATUS_CONNECTION_TRANSFER; - t = (rarch_task_t*)calloc(1, sizeof(*t)); - t->handler = rarch_task_http_transfer_handler; - t->state = http; - t->callback = cb; - t->user_data = user_data; - t->progress = -1; + t = (rarch_task_t*)calloc(1, sizeof(*t)); + + if (!t) + { + free(http); + return false; + } + + t->handler = rarch_task_http_transfer_handler; + t->state = http; + t->callback = cb; + t->user_data = user_data; + t->progress = -1; snprintf(tmp, sizeof(tmp), "%s '%s'", msg_hash_to_str(MSG_DOWNLOADING), path_basename(url)); - t->title = strdup(tmp); + t->title = strdup(tmp); rarch_task_push(t);