BaseTools/DevicePath: Fix potential memory leak

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 46cced287e)
This commit is contained in:
Hao Wu
2018-01-03 16:51:27 +08:00
parent 57bcc39da2
commit 32685c2040
2 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file
DevicePathFromText protocol as defined in the UEFI 2.0 specification.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017 - 2018, 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
@ -3277,6 +3277,17 @@ UefiDevicePathLibConvertTextToDeviceNode (
//
FromText = DevPathFromTextFilePath;
DeviceNode = FromText (DeviceNodeStr);
//
// According to above logic, if 'FromText' is NULL in the 'if' statement,
// then 'ParamStr' must be NULL as well. No memory allocation has been made
// in this case.
//
// The below check is for addressing a false positive potential memory leak
// issue raised from static analysis.
//
if (ParamStr != NULL) {
free (ParamStr);
}
} else {
DeviceNode = FromText (ParamStr);
free (ParamStr);