]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLib/UefiShellLib.c
ShellPkg/ShellLib: Fix potential NULL deference issue
[mirror_edk2.git] / ShellPkg / Library / UefiShellLib / UefiShellLib.c
index 580a1ee612d6c641d0e310b2ad7e630a5ad73732..b17266d623fe08b2c3c19fe97adaa2eb6c8070a3 100644 (file)
@@ -72,6 +72,7 @@ FullyQualifyPath(
 {\r
   CONST CHAR16         *WorkingPath;\r
   CONST CHAR16         *InputPath;\r
+  CHAR16               *CharPtr;\r
   CHAR16               *InputFileSystem;\r
   UINTN                FileSystemCharCount;\r
   CHAR16               *FullyQualifiedPath;\r
@@ -131,7 +132,10 @@ FullyQualifyPath(
         // truncate the new path after the file system part.\r
         //\r
         StrCpyS(FullyQualifiedPath, Size/sizeof(CHAR16), WorkingPath);\r
-        *(StrStr(FullyQualifiedPath, L":") + 1) = CHAR_NULL;\r
+        CharPtr = StrStr(FullyQualifiedPath, L":");\r
+        if (CharPtr != NULL) {\r
+          *(CharPtr + 1) = CHAR_NULL;\r
+        }\r
       } else {\r
         //\r
         // Relative path: start with the working directory and append "\".\r