]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Minor unittest fixes to make Coverity happy.
authorVictor Julien <victor@inliniac.net>
Fri, 30 Mar 2012 15:40:34 +0000 (17:40 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 30 Mar 2012 15:40:34 +0000 (17:40 +0200)
src/decode-ipv6.c
src/detect-bytejump.c
src/detect-bytetest.c
src/detect-content.c
src/detect-dce-iface.c
src/detect-fast-pattern.c
src/detect-flowint.c
src/detect-uricontent.c
src/detect-urilen.c
src/detect.c
src/util-radix-tree.c

index 3adf86006a5bb5e649c9ddd6152f74990ab61308..b147dd4a9acf4e784139aeeac0c4966c9eea402c 100644 (file)
@@ -637,8 +637,10 @@ static int DecodeIPV6FragTest01 (void)   {
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars tv;
     DecodeThreadVars dtv;
     int result = 0;
index f79a14e59b6ef4f9e7219c6bea894ee7b475d932..359e684ce5a3fc1289fae7c40d56cda54c98c93b 100644 (file)
@@ -874,6 +874,9 @@ int DetectBytejumpTestParse08(void) {
  */
 int DetectBytejumpTestParse09(void) {
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 1;
 
     s->alproto = ALPROTO_DCERPC;
index 9ad793e3c303fbb973f51ae5c43952931054b397..51705e19a004fe4c5d667291905f47f62b262e54 100644 (file)
@@ -1029,6 +1029,9 @@ int DetectBytetestTestParse18(void) {
  */
 int DetectBytetestTestParse19(void) {
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 1;
 
     s->alproto = ALPROTO_DCERPC;
index e264dcdbf04ee3a68ece16191a9c7fc6e8a0d330..7ff1dd90c91693194463a4e3bacda8e074a8b905 100644 (file)
@@ -1041,6 +1041,9 @@ int DetectContentParseTest18(void)
     SigFree(s);
 
     s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     result &= (DetectContentSetup(de_ctx, s, "\"one\"") == 0);
     result &= (s->sm_lists[DETECT_SM_LIST_DMATCH] == NULL && s->sm_lists[DETECT_SM_LIST_PMATCH] != NULL);
 
index 691fd0c41496b69d192c1ae398ea0e8310941330..2743ae4fdaf84f40f8ec47a2f3c75e452ca05be1 100644 (file)
@@ -402,6 +402,9 @@ static int DetectDceIfaceTestParse01(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -442,6 +445,9 @@ static int DetectDceIfaceTestParse02(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -482,6 +488,9 @@ static int DetectDceIfaceTestParse03(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -518,6 +527,9 @@ static int DetectDceIfaceTestParse04(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -598,6 +610,9 @@ static int DetectDceIfaceTestParse06(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -638,6 +653,9 @@ static int DetectDceIfaceTestParse07(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -676,6 +694,9 @@ static int DetectDceIfaceTestParse07(void)
 static int DetectDceIfaceTestParse08(void)
 {
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -716,6 +737,9 @@ static int DetectDceIfaceTestParse09(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -752,6 +776,9 @@ static int DetectDceIfaceTestParse10(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 0;
     DetectDceIfaceData *did = NULL;
     uint8_t test_uuid[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34,
@@ -792,6 +819,9 @@ static int DetectDceIfaceTestParse11(void)
     SCEnter();
 
     Signature *s = SigAlloc();
+    if (s == NULL)
+        return 0;
+
     int result = 1;
 
     result &= (DetectDceIfaceSetup(NULL, s, "12345678-1234-1234-1234-123456789ABC,>1,ay_frag") == -1);
index da68d33850a3f55e64ae18275fecae6b132b4bc8..15e05acb5f8aef0920425d2b28ad4d80e6283dc9 100644 (file)
@@ -11207,19 +11207,19 @@ int DetectFastPatternTest387(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSMDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -11243,19 +11243,20 @@ int DetectFastPatternTest388(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSMDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -12248,26 +12249,6 @@ int DetectFastPatternTest424(void)
     DetectEngineCtxFree(de_ctx);
     return result;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 int DetectFastPatternTest425(void)
 {
@@ -12390,19 +12371,20 @@ int DetectFastPatternTest428(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -12426,19 +12408,20 @@ int DetectFastPatternTest429(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -13432,27 +13415,6 @@ int DetectFastPatternTest465(void)
     return result;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 int DetectFastPatternTest466(void)
 {
     DetectEngineCtx *de_ctx = NULL;
@@ -13574,19 +13536,19 @@ int DetectFastPatternTest469(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -13610,19 +13572,20 @@ int DetectFastPatternTest470(void)
     if (de_ctx->sig_list == NULL)
         goto end;
 
-    result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HSCDMATCH];
-    if (sm != NULL) {
-        DetectContentData *ud = sm->ctx;
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (sm == NULL) {
+        goto end;
+    }
+
+    DetectContentData *ud = sm->ctx;
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
index c7802fc3022e0e2c4f489e24d4429afedc82825f..46db492b9a25da692a56fb8e8d286b45b2c179ad 100644 (file)
@@ -455,7 +455,7 @@ int DetectFlowintTestParseVal01(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,=,35");
@@ -469,10 +469,6 @@ int DetectFlowintTestParseVal01(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -486,7 +482,7 @@ int DetectFlowintTestParseVar01(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,=,targetvar");
@@ -503,10 +499,6 @@ int DetectFlowintTestParseVar01(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -520,7 +512,7 @@ int DetectFlowintTestParseVal02(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,+,35");
@@ -534,10 +526,6 @@ int DetectFlowintTestParseVal02(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -551,7 +539,7 @@ int DetectFlowintTestParseVar02(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,+,targetvar");
@@ -568,10 +556,6 @@ int DetectFlowintTestParseVar02(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -585,7 +569,7 @@ int DetectFlowintTestParseVal03(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,-,35");
@@ -599,10 +583,6 @@ int DetectFlowintTestParseVal03(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -616,7 +596,7 @@ int DetectFlowintTestParseVar03(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,-,targetvar");
@@ -633,10 +613,6 @@ int DetectFlowintTestParseVar03(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 
@@ -651,7 +627,7 @@ int DetectFlowintTestParseVal04(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,==,35");
@@ -665,10 +641,6 @@ int DetectFlowintTestParseVal04(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -682,7 +654,7 @@ int DetectFlowintTestParseVar04(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,==,targetvar");
@@ -699,10 +671,6 @@ int DetectFlowintTestParseVar04(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -716,7 +684,7 @@ int DetectFlowintTestParseVal05(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,!=,35");
@@ -730,10 +698,6 @@ int DetectFlowintTestParseVal05(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -747,7 +711,7 @@ int DetectFlowintTestParseVar05(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar,!=,targetvar");
@@ -764,10 +728,6 @@ int DetectFlowintTestParseVar05(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -781,7 +741,7 @@ int DetectFlowintTestParseVal06(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, >,35");
@@ -795,10 +755,6 @@ int DetectFlowintTestParseVal06(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -812,7 +768,7 @@ int DetectFlowintTestParseVar06(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, >,targetvar");
@@ -829,10 +785,6 @@ int DetectFlowintTestParseVar06(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -846,7 +798,7 @@ int DetectFlowintTestParseVal07(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, >= ,35");
@@ -860,10 +812,6 @@ int DetectFlowintTestParseVal07(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -877,7 +825,7 @@ int DetectFlowintTestParseVar07(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, >= ,targetvar");
@@ -894,10 +842,6 @@ int DetectFlowintTestParseVar07(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -911,7 +855,7 @@ int DetectFlowintTestParseVal08(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, <= ,35");
@@ -925,10 +869,6 @@ int DetectFlowintTestParseVal08(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -942,7 +882,7 @@ int DetectFlowintTestParseVar08(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, <= ,targetvar");
@@ -959,10 +899,6 @@ int DetectFlowintTestParseVar08(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -976,7 +912,7 @@ int DetectFlowintTestParseVal09(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, < ,35");
@@ -990,10 +926,6 @@ int DetectFlowintTestParseVal09(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -1007,7 +939,7 @@ int DetectFlowintTestParseVar09(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, < ,targetvar");
@@ -1024,10 +956,6 @@ int DetectFlowintTestParseVar09(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
@@ -1041,7 +969,7 @@ int DetectFlowintTestParseIsset10(void)
     DetectEngineCtx *de_ctx;
     de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL)
-        goto error;
+        return 0;
     de_ctx->flags |= DE_QUIET;
 
     sfd = DetectFlowintParse(de_ctx, "myvar, isset");
@@ -1071,10 +999,6 @@ int DetectFlowintTestParseIsset10(void)
     DetectEngineCtxFree(de_ctx);
 
     return result;
-error:
-    if (de_ctx)
-        DetectEngineCtxFree(de_ctx);
-    return result;
 }
 
 /**
index 4bd5fbf155fd760cfbfb2afcc7a8c4d13c734901..e480522fd2ab8729bd7045f889a61ed57bde1837 100644 (file)
@@ -389,25 +389,18 @@ static int HTTPUriTest01(void) {
     if (tx->request_method_number != M_GET ||
             tx->request_protocol_number != HTTP_1_1)
     {
-        printf("expected method GET and got %s: , expected protocol "
-                "HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
-                bstr_tocstr(tx->request_protocol));
         goto end;
     }
 
     if ((tx->parsed_uri->hostname == NULL) ||
             (bstr_cmpc(tx->parsed_uri->hostname, "www.example.com") != 0))
     {
-        printf("expected www.example.com as hostname, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->hostname));
         goto end;
     }
 
     if ((tx->parsed_uri->path == NULL) ||
             (bstr_cmpc(tx->parsed_uri->path, "/images.gif") != 0))
     {
-        printf("expected /images.gif as path, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->path));
         goto end;
     }
 
@@ -456,25 +449,18 @@ static int HTTPUriTest02(void) {
     if (tx->request_method_number != M_GET ||
             tx->request_protocol_number != HTTP_1_1)
     {
-        printf("expected method GET and got %s: , expected protocol "
-                "HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
-                bstr_tocstr(tx->request_protocol));
         goto end;
     }
 
     if ((tx->parsed_uri->hostname == NULL) ||
             (bstr_cmpc(tx->parsed_uri->hostname, "www.example.com") != 0))
     {
-        printf("expected www.example.com as hostname, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->hostname));
         goto end;
     }
 
     if ((tx->parsed_uri->path == NULL) ||
             (bstr_cmpc(tx->parsed_uri->path, "/images.gif") != 0))
     {
-        printf("expected /images.gif as path, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->path));
         goto end;
     }
 
@@ -525,25 +511,18 @@ static int HTTPUriTest03(void) {
     if (tx->request_method_number != M_UNKNOWN ||
             tx->request_protocol_number != HTTP_1_1)
     {
-        printf("expected method GET and got %s: , expected protocol "
-                "HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
-                bstr_tocstr(tx->request_protocol));
         goto end;
     }
 
    if ((tx->parsed_uri->hostname == NULL) ||
             (bstr_cmpc(tx->parsed_uri->hostname, "www.example.com") != 0))
     {
-        printf("expected www.example.com as hostname, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->hostname));
         goto end;
     }
 
     if ((tx->parsed_uri->path == NULL) ||
             (bstr_cmpc(tx->parsed_uri->path, "/images.gif") != 0))
     {
-        printf("expected /images.gif as path, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->path));
         goto end;
     }
 
@@ -587,7 +566,6 @@ static int HTTPUriTest04(void) {
     htp_state = f.alstate;
     if (htp_state == NULL) {
         printf("no http state: ");
-        result = 0;
         goto end;
     }
 
@@ -596,28 +574,18 @@ static int HTTPUriTest04(void) {
     if (tx->request_method_number != M_GET ||
             tx->request_protocol_number != HTTP_1_1)
     {
-        printf("expected method GET and got %s: , expected protocol "
-                "HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
-                bstr_tocstr(tx->request_protocol));
-        result = 0;
         goto end;
     }
 
     if ((tx->parsed_uri->hostname == NULL) ||
             (bstr_cmpc(tx->parsed_uri->hostname, "www.example.com") != 0))
     {
-        printf("expected www.example.com as hostname, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->hostname));
-        result = 0;
         goto end;
     }
 
     if ((tx->parsed_uri->path == NULL) ||
            (bstr_cmpc(tx->parsed_uri->path, "/images.gif") != 0))
     {
-        printf("expected /images.gif as path, but got: %s \n",
-                bstr_tocstr(tx->parsed_uri->path));
-        result = 0;
         goto end;
     }
 
index 76d02f41fdcaf7b3d89850553c08cc8cafdc8d5d..eb7621e6c5c1374d7f0e45578e58185e6a4b0513 100644 (file)
@@ -289,10 +289,8 @@ DetectUrilenData *DetectUrilenParse (char *urilenstr)
         }
     }
 
-    if (arg1 != NULL)
-        pcre_free_substring(arg1);
-    if (arg2 != NULL)
-        pcre_free_substring(arg2);
+    pcre_free_substring(arg1);
+    pcre_free_substring(arg2);
     if (arg3 != NULL)
         pcre_free_substring(arg3);
     if (arg4 != NULL)
index c2c945d909a245fe1be70d8708a37ad205314ce3..df2bdca6613e452d9fc9d7fb14e0bf5362a9f10e 100644 (file)
@@ -6293,8 +6293,10 @@ int SigTest24IPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 0;
@@ -6397,8 +6399,10 @@ int SigTest25NegativeIPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
     int result = 1;
@@ -6508,8 +6512,10 @@ int SigTest26TCPV4Keyword(void)
         return 0;
 
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
 
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
@@ -6621,8 +6627,10 @@ int SigTest27NegativeTCPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
     int result = 0;
@@ -6745,8 +6753,10 @@ int SigTest28TCPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
     int result = 0;
@@ -6869,8 +6879,10 @@ int SigTest29NegativeTCPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 0;
@@ -6992,8 +7004,10 @@ int SigTest30UDPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7115,8 +7129,10 @@ int SigTest31NegativeUDPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7232,8 +7248,10 @@ int SigTest32UDPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7347,8 +7365,10 @@ int SigTest33NegativeUDPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7464,8 +7484,10 @@ int SigTest34ICMPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7584,8 +7606,10 @@ int SigTest35NegativeICMPV4Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx;
     int result = 1;
@@ -7715,8 +7739,10 @@ int SigTest36ICMPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
@@ -7843,8 +7869,10 @@ int SigTest37NegativeICMPV6Keyword(void)
     if (p1 == NULL)
         return 0;
     Packet *p2 = SCMalloc(SIZE_OF_PACKET);
-    if (p2 == NULL)
+    if (p2 == NULL) {
+        SCFree(p1);
         return 0;
+    }
     ThreadVars th_v;
     DetectEngineThreadCtx *det_ctx = NULL;
     int result = 1;
index 0b607f9b28b743a91d2f5b55646f3b7a30ea5b96..2d12d1759b11fcc42367a09bf935f32c7fa8d0e5 100644 (file)
@@ -4176,8 +4176,10 @@ int SCRadixTestIPV4NetblockInsertion26(void)
 
     str = SCStrdup("Hello1");
     bzero(&servaddr, sizeof(servaddr));
-    if (inet_pton(AF_INET, "0.0.0.0", &servaddr.sin_addr) <= 0)
+    if (inet_pton(AF_INET, "0.0.0.0", &servaddr.sin_addr) <= 0) {
+        SCFree(str);
         return 0;
+    }
     tmp = SCRadixAddKeyIPV4Netblock((uint8_t *)&servaddr.sin_addr, tree, str, 7);
     if (!tmp) {
         printf("Not inserted correctly 3 :");