]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[http] Add missing check for memory allocation failure
authorMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 13:20:45 +0000 (15:20 +0200)
committerMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 13:20:59 +0000 (15:20 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcp/httpconn.c

index a2c01a418a72181e3811fcb4ff9aac59c10c6caa..2cfca9c94b7de4a00414a1e7416c143284056636 100644 (file)
@@ -277,6 +277,10 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 
        /* Allocate and initialise structure */
        conn = zalloc ( sizeof ( *conn ) );
+       if ( ! conn ) {
+               rc = -ENOMEM;
+               goto err_alloc;
+       }
        ref_init ( &conn->refcnt, http_conn_free );
        conn->uri = uri_get ( uri );
        conn->scheme = scheme;
@@ -310,5 +314,6 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
                conn->scheme->name, conn->uri->host, port, strerror ( rc ) );
        http_conn_close ( conn, rc );
        ref_put ( &conn->refcnt );
+ err_alloc:
        return rc;
 }