(task_http.c) Cleanups/plug possible memory leaks

This commit is contained in:
twinaphex 2016-01-21 03:19:14 +01:00
parent e8d86ef013
commit 1f039b53f3
2 changed files with 29 additions and 8 deletions

View File

@ -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;

View File

@ -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);