mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 18:11:49 +03:00
[http] Add missing check for memory allocation failure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -277,6 +277,10 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
|
|||||||
|
|
||||||
/* Allocate and initialise structure */
|
/* Allocate and initialise structure */
|
||||||
conn = zalloc ( sizeof ( *conn ) );
|
conn = zalloc ( sizeof ( *conn ) );
|
||||||
|
if ( ! conn ) {
|
||||||
|
rc = -ENOMEM;
|
||||||
|
goto err_alloc;
|
||||||
|
}
|
||||||
ref_init ( &conn->refcnt, http_conn_free );
|
ref_init ( &conn->refcnt, http_conn_free );
|
||||||
conn->uri = uri_get ( uri );
|
conn->uri = uri_get ( uri );
|
||||||
conn->scheme = scheme;
|
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 ) );
|
conn->scheme->name, conn->uri->host, port, strerror ( rc ) );
|
||||||
http_conn_close ( conn, rc );
|
http_conn_close ( conn, rc );
|
||||||
ref_put ( &conn->refcnt );
|
ref_put ( &conn->refcnt );
|
||||||
|
err_alloc:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user