Skip to content

Commit

Permalink
detect/content: Use SCCalloc instead of malloc/memset
Browse files Browse the repository at this point in the history
This commit replaces a SCMalloc/memset with SCCalloc
  • Loading branch information
jlucovsky committed Jan 22, 2022
1 parent 096d8f6 commit 6149c21
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/detect-content.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,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;
Expand Down

0 comments on commit 6149c21

Please sign in to comment.