]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http2: fix a resource leak in push_promise()
authorKamil Dudka <kdudka@redhat.com>
Fri, 30 Apr 2021 16:18:02 +0000 (18:18 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 1 May 2021 21:40:14 +0000 (23:40 +0200)
... detected by Coverity:

Error: RESOURCE_LEAK (CWE-772):
lib/http2.c:532: alloc_fn: Storage is returned from allocation function "duphandle".
lib/http2.c:532: var_assign: Assigning: "newhandle" = storage returned from "duphandle(data)".
lib/http2.c:552: noescape: Resource "newhandle" is not freed or pointed-to in "set_transfer_url".
lib/http2.c:555: leaked_storage: Variable "newhandle" going out of scope leaks the storage it points to.

Closes #6986

lib/http2.c

index ad7ae1d1b85cf475ed923ce4f4362ab886051ed4..d59571ed23d2eeac5cda62b0532fa395a35bd77a 100644 (file)
@@ -581,6 +581,7 @@ static int push_promise(struct Curl_easy *data,
 
     rv = set_transfer_url(newhandle, &heads);
     if(rv) {
+      (void)Curl_close(&newhandle);
       rv = CURL_PUSH_DENY;
       goto fail;
     }