mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(net_http) Prevent NULL pointer dereferences
This commit is contained in:
parent
015367b741
commit
8a6cce1964
@ -244,6 +244,9 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
|||||||
|
|
||||||
void net_http_connection_free(struct http_connection_t *conn)
|
void net_http_connection_free(struct http_connection_t *conn)
|
||||||
{
|
{
|
||||||
|
if (!conn)
|
||||||
|
return;
|
||||||
|
|
||||||
if (conn->urlcopy)
|
if (conn->urlcopy)
|
||||||
free(conn->urlcopy);
|
free(conn->urlcopy);
|
||||||
}
|
}
|
||||||
@ -311,6 +314,8 @@ error:
|
|||||||
|
|
||||||
int net_http_fd(struct http_t *state)
|
int net_http_fd(struct http_t *state)
|
||||||
{
|
{
|
||||||
|
if (!state)
|
||||||
|
return 0;
|
||||||
return state->fd;
|
return state->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +323,7 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
|
|||||||
{
|
{
|
||||||
ssize_t newlen = 0;
|
ssize_t newlen = 0;
|
||||||
|
|
||||||
if (state->error)
|
if (!state || state->error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (state->part < P_BODY)
|
if (state->part < P_BODY)
|
||||||
@ -511,11 +516,16 @@ fail:
|
|||||||
|
|
||||||
int net_http_status(struct http_t *state)
|
int net_http_status(struct http_t *state)
|
||||||
{
|
{
|
||||||
return state->status;
|
if (state)
|
||||||
|
return state->status;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error)
|
uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error)
|
||||||
{
|
{
|
||||||
|
if (!state)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (!accept_error &&
|
if (!accept_error &&
|
||||||
(state->error || state->status<200 || state->status>299))
|
(state->error || state->status<200 || state->status>299))
|
||||||
{
|
{
|
||||||
@ -532,6 +542,9 @@ uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error)
|
|||||||
|
|
||||||
void net_http_delete(struct http_t *state)
|
void net_http_delete(struct http_t *state)
|
||||||
{
|
{
|
||||||
|
if (!state)
|
||||||
|
return;
|
||||||
|
|
||||||
if (state->fd != -1)
|
if (state->fd != -1)
|
||||||
socket_close(state->fd);
|
socket_close(state->fd);
|
||||||
if (state->data)
|
if (state->data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user