]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ShellParametersProtocol.c
ShellPkg: Refine type cast for pointer subtraction
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellParametersProtocol.c
index 499915521aeec1f27d4dc66266453afd152424ff..8d76fb4be7ff0910d333b1814ed471a9e23099f1 100644 (file)
@@ -5,7 +5,7 @@
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
   Copyright (C) 2014, Red Hat, Inc.\r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1034,9 +1034,9 @@ UpdateStdInStdOutStdErr(
   StrnCpyS(CommandLineCopy, StrSize(CommandLineCopy)/sizeof(CHAR16), NewCommandLine, StrLen(NewCommandLine));\r
 \r
   if (FirstLocation != CommandLineCopy + StrLen(CommandLineCopy)\r
-    && ((UINTN)(FirstLocation - CommandLineCopy) < StrLen(NewCommandLine))\r
+    && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16) < StrLen(NewCommandLine))\r
     ){\r
-    *(NewCommandLine + (UINTN)(FirstLocation - CommandLineCopy)) = CHAR_NULL;\r
+    *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16)) = CHAR_NULL;\r
   }\r
 \r
   if (!EFI_ERROR(Status)) {\r