X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FHexEdit%2FDiskImage.c;fp=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FHexEdit%2FDiskImage.c;h=8deb643f07ccf1b7a2a232b025cf48407ed60dbd;hb=1efda6414f90c515e4ba1a8f996282f2bd322fea;hp=846b102975a1c0f81ad4e73469992fbe3f9fdd51;hpb=ad6040ec9b5bbc462762331f9738b8e42c0b9c80;p=mirror_edk2.git
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
index 846b102975..8deb643f07 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
@@ -1,7 +1,7 @@
/** @file
Functions to deal with Disk buffer.
- Copyright (c) 2005 - 2016, 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
@@ -120,27 +120,23 @@ HDiskImageSetDiskNameOffsetSize (
IN UINTN Size
)
{
- UINTN Len;
- UINTN Index;
+ if (Str == HDiskImage.Name) {
+ //
+ // This function might be called using HDiskImage.FileName as Str.
+ // Directly return without updating HDiskImage.FileName.
+ //
+ return EFI_SUCCESS;
+ }
//
// free the old file name
//
SHELL_FREE_NON_NULL (HDiskImage.Name);
-
- Len = StrLen (Str);
-
- HDiskImage.Name = AllocateZeroPool (2 * (Len + 1));
+ HDiskImage.Name = AllocateCopyPool (StrSize (Str), Str);
if (HDiskImage.Name == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- for (Index = 0; Index < Len; Index++) {
- HDiskImage.Name[Index] = Str[Index];
- }
-
- HDiskImage.Name[Len] = L'\0';
-
HDiskImage.Offset = Offset;
HDiskImage.Size = Size;