]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Properly handle http_endpoint malloc failure.
authorRalph Dolmans <ralph@nlnetlabs.nl>
Thu, 10 Sep 2020 11:05:55 +0000 (13:05 +0200)
committerRalph Dolmans <ralph@nlnetlabs.nl>
Thu, 10 Sep 2020 11:05:55 +0000 (13:05 +0200)
util/netevent.c

index 49ad08a4d9bf27d6c80bf62813118cf704cb9acc..be3b740b592bfb7af78d1d9dbf951f855a2b3068 100644 (file)
@@ -3152,11 +3152,19 @@ comm_point_create_http_handler(struct comm_base *base,
        if(harden_large_queries && bufsize > 512)
                c->http2_stream_max_qbuffer_size = 512;
        c->http2_max_streams = http_max_streams;
-       c->http_endpoint = strdup(http_endpoint);
+       if(!(c->http_endpoint = strdup(http_endpoint))) {
+               log_err("could not strdup http_endpoint");
+               sldns_buffer_free(c->buffer);
+               free(c->timeout);
+               free(c->ev);
+               free(c);
+               return NULL;
+       }
        c->alpn_h2 = 0;
 #ifdef HAVE_NGHTTP2
        if(!(c->h2_session = http2_session_create(c))) {
                log_err("could not create http2 session");
+               free(c->http_endpoint);
                sldns_buffer_free(c->buffer);
                free(c->timeout);
                free(c->ev);
@@ -3166,6 +3174,7 @@ comm_point_create_http_handler(struct comm_base *base,
        if(!(c->h2_session->callbacks = http2_req_callbacks_create())) {
                log_err("could not create http2 callbacks");
                http2_session_delete(c->h2_session);
+               free(c->http_endpoint);
                sldns_buffer_free(c->buffer);
                free(c->timeout);
                free(c->ev);