summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 9c370cc..def3bd3 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -449,38 +449,37 @@ EfiShellGetFilePathFromDevicePath(
; FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode (&FilePath->Header)
){
//
- // all the rest should be file path nodes
+ // If any node is not a file path node, then the conversion can not be completed
//
if ((DevicePathType(&FilePath->Header) != MEDIA_DEVICE_PATH) ||
(DevicePathSubType(&FilePath->Header) != MEDIA_FILEPATH_DP)) {
FreePool(PathForReturn);
- PathForReturn = NULL;
- ASSERT(FALSE);
- } else {
- //
- // append the path part onto the filepath.
- //
- ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
-
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);
- ASSERT (AlignedNode != NULL);
-
- // File Path Device Path Nodes 'can optionally add a "\" separator to
- // the beginning and/or the end of the Path Name string.'
- // (UEFI Spec 2.4 section 9.3.6.4).
- // If necessary, add a "\", but otherwise don't
- // (This is specified in the above section, and also implied by the
- // UEFI Shell spec section 3.7)
- if ((PathSize != 0) &&
- (PathForReturn != NULL) &&
- (PathForReturn[PathSize - 1] != L'\\') &&
- (AlignedNode->PathName[0] != L'\\')) {
- PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);
- }
+ return NULL;
+ }
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);
- FreePool(AlignedNode);
+ //
+ // append the path part onto the filepath.
+ //
+ ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
+
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);
+ ASSERT (AlignedNode != NULL);
+
+ // File Path Device Path Nodes 'can optionally add a "\" separator to
+ // the beginning and/or the end of the Path Name string.'
+ // (UEFI Spec 2.4 section 9.3.6.4).
+ // If necessary, add a "\", but otherwise don't
+ // (This is specified in the above section, and also implied by the
+ // UEFI Shell spec section 3.7)
+ if ((PathSize != 0) &&
+ (PathForReturn != NULL) &&
+ (PathForReturn[PathSize - 1] != L'\\') &&
+ (AlignedNode->PathName[0] != L'\\')) {
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);
}
+
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);
+ FreePool(AlignedNode);
} // for loop of remaining nodes
}
if (PathForReturn != NULL) {