]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c
Fix potential memory access violation
[mirror_edk2.git] / MdeModulePkg / Library / DxeTcpIoLib / DxeTcpIoLib.c
index 110e4890c88f9c244c7febe002a76e33cfbd0dce..2a65422e1c5875b1d7946395766be818b7df73fe 100644 (file)
@@ -913,8 +913,9 @@ TcpIoReceive (
 \r
   FragmentCount = Packet->BlockOpNum;
   Fragment      = AllocatePool (FragmentCount * sizeof (NET_FRAGMENT));
-  if (Fragment == NULL) {
-    return EFI_OUT_OF_RESOURCES;
+  if (Fragment == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
   }
   //
   // Build the fragment table.
@@ -988,8 +989,10 @@ ON_EXIT:
   } else {\r
     TcpIo->RxToken.Tcp6Token.Packet.RxData = NULL;\r
   }\r
-\r
-  FreePool (Fragment);\r
+  \r
+  if (Fragment != NULL) {\r
+    FreePool (Fragment);\r
+  }\r
 
   return Status;\r
 }\r