ShellPkg: Fix memory leak in ShellProtocol.
1. Close unused file handle. 2. Free the local allocated buffer function returned. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19481 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1361,6 +1361,7 @@ EfiShellDeleteFileByName(
|
|||||||
//
|
//
|
||||||
// now delete the file
|
// now delete the file
|
||||||
//
|
//
|
||||||
|
ShellFileHandleRemove(FileHandle);
|
||||||
return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
|
return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2338,6 +2339,8 @@ ShellSearchHandle(
|
|||||||
// recurse with the next part of the pattern
|
// recurse with the next part of the pattern
|
||||||
//
|
//
|
||||||
Status = ShellSearchHandle(NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
|
Status = ShellSearchHandle(NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
|
||||||
|
EfiShellClose(ShellInfoNode->Handle);
|
||||||
|
ShellInfoNode->Handle = NULL;
|
||||||
}
|
}
|
||||||
} else if (!EFI_ERROR(Status)) {
|
} else if (!EFI_ERROR(Status)) {
|
||||||
//
|
//
|
||||||
@@ -2456,6 +2459,7 @@ EfiShellFindFiles(
|
|||||||
; PatternCurrentLocation++);
|
; PatternCurrentLocation++);
|
||||||
PatternCurrentLocation++;
|
PatternCurrentLocation++;
|
||||||
Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
|
Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
|
||||||
|
EfiShellClose(RootFileHandle);
|
||||||
}
|
}
|
||||||
FreePool(RootDevicePath);
|
FreePool(RootDevicePath);
|
||||||
}
|
}
|
||||||
@@ -3260,6 +3264,7 @@ EfiShellGetAlias(
|
|||||||
|
|
||||||
if (Volatile == NULL) {
|
if (Volatile == NULL) {
|
||||||
GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
|
GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
|
||||||
|
FreePool(AliasLower);
|
||||||
return (AddBufferToFreeList(AliasVal));
|
return (AddBufferToFreeList(AliasVal));
|
||||||
}
|
}
|
||||||
RetSize = 0;
|
RetSize = 0;
|
||||||
@@ -3273,6 +3278,7 @@ EfiShellGetAlias(
|
|||||||
if (RetVal != NULL) {
|
if (RetVal != NULL) {
|
||||||
FreePool(RetVal);
|
FreePool(RetVal);
|
||||||
}
|
}
|
||||||
|
FreePool(AliasLower);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {
|
if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {
|
||||||
|
Reference in New Issue
Block a user