mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdePkg/UefiDevicePathLib: Fix the potential memory leak issue
The function DevPathToTextUsbWWID() allocates NewStr when the input SerialNumber lacks a null terminator. However, this allocated memory is never freed after use, resulting in a memory leak. This patch adds the missing FreePool() for NewStr before the function returns, ensuring that the allocated buffer is properly freed and eliminating the potential leak. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
This commit is contained in:
parent
c70637de12
commit
fa461abf8a
1 changed files with 5 additions and 0 deletions
|
|
@ -996,6 +996,7 @@ DevPathToTextUsbWWID (
|
|||
UINT16 Length;
|
||||
|
||||
UsbWWId = DevPath;
|
||||
NewStr = NULL;
|
||||
|
||||
SerialNumberStr = (CHAR16 *)((UINT8 *)UsbWWId + sizeof (USB_WWID_DEVICE_PATH));
|
||||
Length = (UINT16)((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
|
||||
|
|
@ -1018,6 +1019,10 @@ DevPathToTextUsbWWID (
|
|||
UsbWWId->InterfaceNumber,
|
||||
SerialNumberStr
|
||||
);
|
||||
|
||||
if (NewStr != NULL) {
|
||||
FreePool (NewStr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue