X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FHexEdit%2FFileImage.c;fp=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FHexEdit%2FFileImage.c;h=d9fd72cdd2eea475172cab7a46969b603dc6a7b8;hb=1efda6414f90c515e4ba1a8f996282f2bd322fea;hp=2517a57f593dd05afb5f5858297cbf4f175e5bef;hpb=ad6040ec9b5bbc462762331f9738b8e42c0b9c80;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c index 2517a57f59..d9fd72cdd2 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c @@ -1,7 +1,7 @@ /** @file Functions to deal with file buffer. - Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -110,27 +110,22 @@ HFileImageSetFileName ( IN CONST CHAR16 *Str ) { - UINTN Size; - UINTN Index; - + if (Str == HFileImage.FileName) { + // + // This function might be called using HFileImage.FileName as Str. + // Directly return without updating HFileImage.FileName. + // + return EFI_SUCCESS; + } // // free the old file name // SHELL_FREE_NON_NULL (HFileImage.FileName); - - Size = StrLen (Str); - - HFileImage.FileName = AllocateZeroPool (2 * (Size + 1)); + HFileImage.FileName = AllocateCopyPool (StrSize (Str), Str); if (HFileImage.FileName == NULL) { return EFI_OUT_OF_RESOURCES; } - for (Index = 0; Index < Size; Index++) { - HFileImage.FileName[Index] = Str[Index]; - } - - HFileImage.FileName[Size] = L'\0'; - return EFI_SUCCESS; }