Revision: 19531
http://sourceforge.net/p/edk2/code/19531
Author: hwu1225
Date: 2015-12-25 02:09:27 +0000 (Fri, 25 Dec 2015)
Log Message:
-----------
ShellPkg: Fix memory leak in ShellProtocol.
1. Close unused file handle.
2. Free the local allocated buffer function returned.
(Sync patch r19481 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/19481
Modified Paths:
--------------
branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
Modified: branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
===================================================================
--- branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-25
02:08:54 UTC (rev 19530)
+++ branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-25
02:09:27 UTC (rev 19531)
@@ -1361,6 +1361,7 @@
//
// now delete the file
//
+ ShellFileHandleRemove(FileHandle);
return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
}
@@ -2338,6 +2339,8 @@
// recurse with the next part of the pattern
//
Status = ShellSearchHandle(NextFilePatternStart,
UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
+ EfiShellClose(ShellInfoNode->Handle);
+ ShellInfoNode->Handle = NULL;
}
} else if (!EFI_ERROR(Status)) {
//
@@ -2456,6 +2459,7 @@
; PatternCurrentLocation++);
PatternCurrentLocation++;
Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation,
RootFileHandle, FileList, NULL, MapName);
+ EfiShellClose(RootFileHandle);
}
FreePool(RootDevicePath);
}
@@ -3260,6 +3264,7 @@
if (Volatile == NULL) {
GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
+ FreePool(AliasLower);
return (AddBufferToFreeList(AliasVal));
}
RetSize = 0;
@@ -3273,6 +3278,7 @@
if (RetVal != NULL) {
FreePool(RetVal);
}
+ FreePool(AliasLower);
return (NULL);
}
if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits