Browse Source

[http] Add missing check for memory allocation failure

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
f17cf0ecd0
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      src/net/tcp/httpconn.c

+ 5
- 0
src/net/tcp/httpconn.c View File

@@ -277,6 +277,10 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
277 277
 
278 278
 	/* Allocate and initialise structure */
279 279
 	conn = zalloc ( sizeof ( *conn ) );
280
+	if ( ! conn ) {
281
+		rc = -ENOMEM;
282
+		goto err_alloc;
283
+	}
280 284
 	ref_init ( &conn->refcnt, http_conn_free );
281 285
 	conn->uri = uri_get ( uri );
282 286
 	conn->scheme = scheme;
@@ -310,5 +314,6 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
310 314
 		conn->scheme->name, conn->uri->host, port, strerror ( rc ) );
311 315
 	http_conn_close ( conn, rc );
312 316
 	ref_put ( &conn->refcnt );
317
+ err_alloc:
313 318
 	return rc;
314 319
 }

Loading…
Cancel
Save