mirror of https://github.com/acidanthera/audk.git
ShellPkg: Fix bug that fails to change CWD after "map -r".
When "map -r" runs, the mapping list is re-created but gShellCurMapping still points to the old mapping list which is already destroyed. The patch updates the gShellCurMapping to point to the correct location in the new mapping list. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li <huajing.li@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
9cf4518702
commit
055fafe1ce
|
@ -1268,7 +1268,14 @@ ShellCommandCreateInitialMappingsAndPaths(
|
|||
CHAR16 *NewConsistName;
|
||||
EFI_DEVICE_PATH_PROTOCOL **ConsistMappingTable;
|
||||
SHELL_MAP_LIST *MapListNode;
|
||||
CONST CHAR16 *CurDir;
|
||||
CHAR16 *SplitCurDir;
|
||||
CHAR16 *MapName;
|
||||
SHELL_MAP_LIST *MapListItem;
|
||||
|
||||
SplitCurDir = NULL;
|
||||
MapName = NULL;
|
||||
MapListItem = NULL;
|
||||
HandleList = NULL;
|
||||
|
||||
//
|
||||
|
@ -1354,6 +1361,33 @@ ShellCommandCreateInitialMappingsAndPaths(
|
|||
SHELL_FREE_NON_NULL(DevicePathList);
|
||||
|
||||
HandleList = NULL;
|
||||
|
||||
//
|
||||
//gShellCurMapping point to node of current file system in the gShellMapList. When reset all mappings,
|
||||
//all nodes in the gShellMapList will be free. Then gShellCurMapping will be a dangling pointer, So,
|
||||
//after created new mappings, we should reset the gShellCurMapping pointer back to node of current file system.
|
||||
//
|
||||
if (gShellCurMapping != NULL) {
|
||||
gShellCurMapping = NULL;
|
||||
CurDir = gEfiShellProtocol->GetEnv(L"cwd");
|
||||
if (CurDir != NULL) {
|
||||
MapName = AllocateCopyPool (StrSize(CurDir), CurDir);
|
||||
if (MapName == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
SplitCurDir = StrStr (MapName, L":");
|
||||
if (SplitCurDir == NULL) {
|
||||
SHELL_FREE_NON_NULL (MapName);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
*(SplitCurDir + 1) = CHAR_NULL;
|
||||
MapListItem = ShellCommandFindMapItem (MapName);
|
||||
if (MapListItem != NULL) {
|
||||
gShellCurMapping = MapListItem;
|
||||
}
|
||||
SHELL_FREE_NON_NULL (MapName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Count = (UINTN)-1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue