Issue:
when file open is failed, assert was seen due to freeing 0 size page

Reason:
DataSize is remain zero if error is reported in ShellOpenFileByName

Fix:
Update DataSize as soon as FileSize is available

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Udit Kumar <udit.ku...@nxp.com>
Signed-off-by: Vabhav <vabhav.sha...@nxp.com>
---
 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c 
b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
index fbde3bf..6425fc5 100755
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
@@ -509,6 +509,7 @@ ShellCommandRunTftp (
       );
       goto NextHandle;
     }
+    DataSize = FileSize;
 
     Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, 
FileSize, BlockSize, &Data);
     if (EFI_ERROR (Status)) {
@@ -539,7 +540,6 @@ ShellCommandRunTftp (
       goto NextHandle;
     }
 
-    DataSize = FileSize;
     Status = ShellWriteFile (FileHandle, &FileSize, Data);
     if (!EFI_ERROR (Status)) {
       ShellStatus = SHELL_SUCCESS;
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to