mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 08:38:49 -05:00
http2: fix resource leaks in set_transfer_url()
... detected by Coverity: Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:486: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:488: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:493: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:495: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:500: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:502: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Error: RESOURCE_LEAK (CWE-772): lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()". lib/http2.c:505: noescape: Resource "u" is not freed or pointed-to in "curl_url_get". [Note: The source code implementation of the function has been overridden by a builtin model.] lib/http2.c:507: leaked_storage: Variable "u" going out of scope leaks the storage it points to. Closes #6986
This commit is contained in:
parent
8228002cd1
commit
3193170470
24
lib/http2.c
24
lib/http2.c
@ -500,32 +500,42 @@ static int set_transfer_url(struct Curl_easy *data,
|
|||||||
CURLU *u = curl_url();
|
CURLU *u = curl_url();
|
||||||
CURLUcode uc;
|
CURLUcode uc;
|
||||||
char *url;
|
char *url;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
v = curl_pushheader_byname(hp, ":scheme");
|
v = curl_pushheader_byname(hp, ":scheme");
|
||||||
if(v) {
|
if(v) {
|
||||||
uc = curl_url_set(u, CURLUPART_SCHEME, v, 0);
|
uc = curl_url_set(u, CURLUPART_SCHEME, v, 0);
|
||||||
if(uc)
|
if(uc) {
|
||||||
return 1;
|
rc = 1;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v = curl_pushheader_byname(hp, ":authority");
|
v = curl_pushheader_byname(hp, ":authority");
|
||||||
if(v) {
|
if(v) {
|
||||||
uc = curl_url_set(u, CURLUPART_HOST, v, 0);
|
uc = curl_url_set(u, CURLUPART_HOST, v, 0);
|
||||||
if(uc)
|
if(uc) {
|
||||||
return 2;
|
rc = 2;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v = curl_pushheader_byname(hp, ":path");
|
v = curl_pushheader_byname(hp, ":path");
|
||||||
if(v) {
|
if(v) {
|
||||||
uc = curl_url_set(u, CURLUPART_PATH, v, 0);
|
uc = curl_url_set(u, CURLUPART_PATH, v, 0);
|
||||||
if(uc)
|
if(uc) {
|
||||||
return 3;
|
rc = 3;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uc = curl_url_get(u, CURLUPART_URL, &url, 0);
|
uc = curl_url_get(u, CURLUPART_URL, &url, 0);
|
||||||
if(uc)
|
if(uc)
|
||||||
return 4;
|
rc = 4;
|
||||||
|
fail:
|
||||||
curl_url_cleanup(u);
|
curl_url_cleanup(u);
|
||||||
|
if(rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
if(data->state.url_alloc)
|
if(data->state.url_alloc)
|
||||||
free(data->state.url);
|
free(data->state.url);
|
||||||
|
Loading…
Reference in New Issue
Block a user