summaryrefslogtreecommitdiff
path: root/lib/http2.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <daniel@yesql.se>2018-10-03 00:56:29 +0200
committerDaniel Gustafsson <daniel@yesql.se>2018-10-03 23:45:38 +0200
commit2873971d6251b7c1eb278df1ee2b944d7c3fcdba (patch)
tree547fb9b9a1dcc8d9185c277d7c45ba746fad2fee /lib/http2.c
parente182fc1613196540df12bcaa846e79f80aa5432c (diff)
downloadcurl-2873971d6251b7c1eb278df1ee2b944d7c3fcdba.tar.gz
memory: ensure to check allocation results
The result of a memory allocation should always be checked, as we may run under memory pressure where even a small allocation can fail. This adds checking and error handling to a few cases where the allocation wasn't checked for success. In the ftp case, the freeing of the path variable is moved ahead of the allocation since there is little point in keeping it around across the strdup, and the separation makes for more readable code. In nwlib, the lock is aslo freed in the error path. Also bumps the copyright years on affected files. Closes #3084 Reviewed-by: Jay Satiro <raysatiro@yahoo.com> Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Diffstat (limited to 'lib/http2.c')
-rw-r--r--lib/http2.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/http2.c b/lib/http2.c
index 29edfba7a..ed47b73b2 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -957,6 +957,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
stream->push_headers_alloc = 10;
stream->push_headers = malloc(stream->push_headers_alloc *
sizeof(char *));
+ if(!stream->push_headers)
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
stream->push_headers_used = 0;
}
else if(stream->push_headers_used ==