mirror of
https://github.com/libretro/RetroArch
synced 2025-02-09 00:40:09 +00:00
Plug potential memleaks in rarch_task_push_http_transfer
This commit is contained in:
parent
1f039b53f3
commit
89481d6d2e
@ -206,12 +206,12 @@ static bool rarch_task_http_finder(rarch_task_t *task, void *user_data)
|
|||||||
|
|
||||||
bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task_callback_t cb, void *user_data)
|
bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
rarch_task_t *t;
|
|
||||||
http_handle_t *http;
|
|
||||||
struct http_connection_t *conn;
|
struct http_connection_t *conn;
|
||||||
char tmp[PATH_MAX_LENGTH];
|
char tmp[PATH_MAX_LENGTH];
|
||||||
|
rarch_task_t *t = NULL;
|
||||||
|
http_handle_t *http = NULL;
|
||||||
|
|
||||||
if (!url || !*url)
|
if (string_is_empty(url))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Concurrent download of the same file is not allowed */
|
/* Concurrent download of the same file is not allowed */
|
||||||
@ -229,7 +229,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task
|
|||||||
http = (http_handle_t*)calloc(1, sizeof(*http));
|
http = (http_handle_t*)calloc(1, sizeof(*http));
|
||||||
|
|
||||||
if (!http)
|
if (!http)
|
||||||
return false;
|
goto error;
|
||||||
|
|
||||||
http->connection.handle = conn;
|
http->connection.handle = conn;
|
||||||
http->connection.cb = &cb_http_conn_default;
|
http->connection.cb = &cb_http_conn_default;
|
||||||
@ -238,14 +238,10 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task
|
|||||||
strlcpy(http->connection.elem1, type, sizeof(http->connection.elem1));
|
strlcpy(http->connection.elem1, type, sizeof(http->connection.elem1));
|
||||||
|
|
||||||
http->status = HTTP_STATUS_CONNECTION_TRANSFER;
|
http->status = HTTP_STATUS_CONNECTION_TRANSFER;
|
||||||
|
|
||||||
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
{
|
goto error;
|
||||||
free(http);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
t->handler = rarch_task_http_transfer_handler;
|
t->handler = rarch_task_http_transfer_handler;
|
||||||
t->state = http;
|
t->state = http;
|
||||||
@ -259,4 +255,14 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task
|
|||||||
rarch_task_push(t);
|
rarch_task_push(t);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (conn)
|
||||||
|
net_http_connection_free(conn);
|
||||||
|
if (t)
|
||||||
|
free(t);
|
||||||
|
if (http)
|
||||||
|
free(http);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user