]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: update code for NULL pointer check.
authorFu Siyuan <siyuan.fu@intel.com>
Mon, 23 May 2016 03:02:01 +0000 (11:02 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Tue, 24 May 2016 08:37:42 +0000 (16:37 +0800)
This patch updates the HTTP driver to initialize the local variable for NULL
and check the NULL pointer before dereference it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
NetworkPkg/HttpDxe/HttpImpl.c

index f4ae28aec98f6a364b8e354d856005488c20289e..7ee661316e0f19b4ef4ad027fdc1adfe194d1d9a 100644 (file)
@@ -253,6 +253,7 @@ EfiHttpRequest (
   // Initializations\r
   //\r
   Url = NULL;\r
+  UrlParser = NULL;\r
   HostName = NULL;\r
   RequestMsg = NULL;\r
   HostNameStr = NULL;\r
@@ -1063,7 +1064,7 @@ HttpResponseWorker (
     if (SizeofHeaders != 0) {\r
       HeaderTmp = AllocateZeroPool (SizeofHeaders);\r
       if (HeaderTmp == NULL) {\r
-        goto Error;\r
+        goto Error2;\r
       }\r
 \r
       CopyMem (HeaderTmp, Tmp, SizeofHeaders);\r
@@ -1075,7 +1076,7 @@ HttpResponseWorker (
       //\r
       if (mHttpUtilities == NULL) {\r
         Status = EFI_NOT_READY;\r
-        goto Error;\r
+        goto Error2;\r
       }\r
 \r
       //\r
@@ -1089,7 +1090,7 @@ HttpResponseWorker (
                                  &HttpMsg->HeaderCount\r
                                  );\r
       if (EFI_ERROR (Status)) {\r
-        goto Error;\r
+        goto Error2;\r
       }\r
 \r
       FreePool (HttpHeaders);\r
@@ -1214,7 +1215,7 @@ HttpResponseWorker (
                     &HttpInstance->TimeoutEvent\r
                     );\r
     if (EFI_ERROR (Status)) {\r
-      goto Error;\r
+      goto Error2;\r
     }\r
   }\r
 \r
@@ -1223,7 +1224,7 @@ HttpResponseWorker (
   //\r
   Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
   if (EFI_ERROR (Status)) {\r
-    goto Error;\r
+    goto Error2;\r
   }\r
 \r
   //\r
@@ -1234,7 +1235,7 @@ HttpResponseWorker (
   gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    goto Error;\r
+    goto Error2;\r
   }\r
 \r
   FreePool (Wrap);\r
@@ -1258,7 +1259,9 @@ Exit:
   return Status;\r
 \r
 Error2:\r
-  NetMapInsertHead (&HttpInstance->TxTokens, ValueInItem->HttpToken, ValueInItem);\r
+  if (ValueInItem != NULL) {\r
+    NetMapInsertHead (&HttpInstance->TxTokens, ValueInItem->HttpToken, ValueInItem);\r
+  }\r
 \r
 Error:\r
   HttpTcpTokenCleanup (Wrap);\r