]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/content: Use SCCalloc instead of malloc/memset
authorJeff Lucovsky <jeff@lucovsky.org>
Fri, 21 Jan 2022 14:45:56 +0000 (09:45 -0500)
committerVictor Julien <vjulien@oisf.net>
Thu, 10 Nov 2022 13:42:44 +0000 (15:42 +0200)
This commit replaces a SCMalloc/memset with SCCalloc

src/detect-content.c

index e3dbd853791c16b00075967f1ff31aa057327de9..fa9e078dc60fb249db489855cb0034e6cd78774d 100644 (file)
@@ -220,14 +220,12 @@ DetectContentData *DetectContentParse(SpmGlobalThreadCtx *spm_global_thread_ctx,
         return NULL;
     }
 
-    cd = SCMalloc(sizeof(DetectContentData) + len);
+    cd = SCCalloc(1, sizeof(DetectContentData) + len);
     if (unlikely(cd == NULL)) {
         SCFree(content);
         exit(EXIT_FAILURE);
     }
 
-    memset(cd, 0, sizeof(DetectContentData) + len);
-
     cd->content = (uint8_t *)cd + sizeof(DetectContentData);
     memcpy(cd->content, content, len);
     cd->content_len = len;