]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue.
[mirror_edk2.git] / ShellPkg / DynamicCommand / TftpDynamicCommand / Tftp.c
index e2491cd54cae5b5e970cb020bd8c3aed1493e121..44be6d4e76f4bd754b007ba00d024797664a684f 100644 (file)
@@ -519,6 +519,8 @@ RunTftp (
       goto NextHandle;\r
     }\r
 \r
+    DataSize = FileSize;\r
+\r
     if (!EFI_ERROR (ShellFileExists (LocalFilePath))) {\r
       ShellDeleteFileByName (LocalFilePath);\r
     }\r
@@ -539,7 +541,6 @@ RunTftp (
       goto NextHandle;\r
     }\r
 \r
-    DataSize = FileSize;\r
     Status = ShellWriteFile (FileHandle, &FileSize, Data);\r
     if (!EFI_ERROR (Status)) {\r
       ShellStatus = SHELL_SUCCESS;\r