]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
htp: fix pointer check logic
authorVictor Julien <victor@inliniac.net>
Wed, 26 Feb 2014 06:01:09 +0000 (07:01 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 26 Feb 2014 06:07:05 +0000 (07:07 +0100)
Don't check pointer after it has already been used.

Coverity 1047545

src/app-layer-htp.c

index 7e132aa8fa2535ba0493055efb634d8be39850e8..194b57971efd90e019b1f140e1d9d69acf0f4fd2 100644 (file)
@@ -1957,6 +1957,10 @@ void HTPFreeConfig(void)
 static int HTPCallbackRequest(htp_tx_t *tx) {
     SCEnter();
 
+    if (tx == NULL) {
+        SCReturnInt(HTP_ERROR);
+    }
+
     HtpState *hstate = htp_connp_get_user_data(tx->connp);
     if (hstate == NULL) {
         SCReturnInt(HTP_ERROR);
@@ -1967,16 +1971,14 @@ static int HTPCallbackRequest(htp_tx_t *tx) {
 
     SCLogDebug("HTTP request completed");
 
-    if (tx != NULL) {
-        HTPErrorCheckTxRequestFlags(hstate, tx);
+    HTPErrorCheckTxRequestFlags(hstate, tx);
 
-        HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx);
-        if (htud != NULL) {
-            if (htud->tsflags & HTP_FILENAME_SET) {
-                SCLogDebug("closing file that was being stored");
-                (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER);
-                htud->tsflags &= ~HTP_FILENAME_SET;
-            }
+    HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx);
+    if (htud != NULL) {
+        if (htud->tsflags & HTP_FILENAME_SET) {
+            SCLogDebug("closing file that was being stored");
+            (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER);
+            htud->tsflags &= ~HTP_FILENAME_SET;
         }
     }