From: Michael Brown Date: Tue, 21 Mar 2017 13:20:45 +0000 (+0200) Subject: [http] Add missing check for memory allocation failure X-Git-Tag: v1.20.1~271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f17cf0ecd0363523dde781338fb1f3b5f5a7c6f7;p=thirdparty%2Fipxe.git [http] Add missing check for memory allocation failure Signed-off-by: Michael Brown --- diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c index a2c01a418..2cfca9c94 100644 --- a/src/net/tcp/httpconn.c +++ b/src/net/tcp/httpconn.c @@ -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; }