NetworkPkg/HttpBootDxe: Avoid the potential memory leak when eror happen.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wang Fan <fan.wang@intel.com>
This commit is contained in:
Jiaxin Wu 2017-12-21 13:32:20 +08:00
parent 9c14f76bae
commit 0dc5929645
2 changed files with 8 additions and 1 deletions

View File

@ -422,6 +422,9 @@ HttpBootParseDhcp4Packet (
if (!IsProxyOffer) { if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly; OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
} else { } else {
if (Cache4->UriParser != NULL) {
FreePool (Cache4->UriParser);
}
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
} }

View File

@ -123,6 +123,7 @@ HttpBootStart (
EFI_STATUS Status; EFI_STATUS Status;
CHAR8 *Uri; CHAR8 *Uri;
Uri = NULL;
if (Private == NULL || FilePath == NULL) { if (Private == NULL || FilePath == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -154,6 +155,9 @@ HttpBootStart (
// //
Status = HttpBootStop (Private); Status = HttpBootStop (Private);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Uri != NULL) {
FreePool (Uri);
}
return Status; return Status;
} }
} else { } else {