mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
1f7e7e70d2
commit
46cced287e
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Definition for Device Path Tool.
|
Definition for Device Path Tool.
|
||||||
|
|
||||||
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -190,5 +190,6 @@ int main(int argc, CHAR8 *argv[])
|
||||||
}
|
}
|
||||||
PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);
|
PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
free(Str16);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
DevicePathFromText protocol as defined in the UEFI 2.0 specification.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -3277,6 +3277,17 @@ UefiDevicePathLibConvertTextToDeviceNode (
|
||||||
//
|
//
|
||||||
FromText = DevPathFromTextFilePath;
|
FromText = DevPathFromTextFilePath;
|
||||||
DeviceNode = FromText (DeviceNodeStr);
|
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 {
|
} else {
|
||||||
DeviceNode = FromText (ParamStr);
|
DeviceNode = FromText (ParamStr);
|
||||||
free (ParamStr);
|
free (ParamStr);
|
||||||
|
|
Loading…
Reference in New Issue