summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index e11a3cccea..695d090926 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -2802,11 +2802,18 @@ ParseHandleDatabaseForChildControllers(
FreePool (DriverBindingHandleBuffer);
+ if (MatchingHandleBuffer == NULL || *MatchingHandleCount == 0) {
+ //
+ // The caller is not interested in the actual handles, or we've found none.
+ //
+ FreePool (HandleBufferForReturn);
+ HandleBufferForReturn = NULL;
+ }
+
if (MatchingHandleBuffer != NULL) {
*MatchingHandleBuffer = HandleBufferForReturn;
- } else {
- FreePool(HandleBufferForReturn);
}
+
ASSERT ((MatchingHandleBuffer == NULL) ||
(*MatchingHandleCount == 0 && *MatchingHandleBuffer == NULL) ||
(*MatchingHandleCount != 0 && *MatchingHandleBuffer != NULL));