NetworkPkg:Fix Network memory leak when calling GetModeData interface
Multiple network protocols have a GetModeData() interface, which may allocate memory resource in the return mode data structure. It's callers responsibility to free these buffers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19758 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -211,6 +211,13 @@ UpdateDns4Name (
|
||||
ModeData.DnsConfigData.LocalPort
|
||||
);
|
||||
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
|
||||
if (gDnsControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gDnsControllerNameTable);
|
||||
gDnsControllerNameTable = NULL;
|
||||
@@ -281,6 +288,13 @@ UpdateDns6Name (
|
||||
ModeData.DnsConfigData.LocalPort
|
||||
);
|
||||
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
|
||||
if (gDnsControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gDnsControllerNameTable);
|
||||
gDnsControllerNameTable = NULL;
|
||||
|
Reference in New Issue
Block a user