Actions
Bug #6745
closedutil/mime: Memory leak at util-decode-mime.c:MimeDecInitParser
Affected Versions:
Effort:
low
Difficulty:
low
Label:
Description
Memory allocated at util-decode-mime.c:2422 for mimeMsg structure, could be lost if state->stack->top == NULL ,
condition is true, since there is no corresponding free call for this case
MimeDecParseState * MimeDecInitParser(void *data,
int (*DataChunkProcessorFunc)(const uint8_t *chunk, uint32_t len,
MimeDecParseState *state))
{
MimeDecParseState *state;
MimeDecEntity *mimeMsg;
state = SCCalloc(1, sizeof(MimeDecParseState));
if (unlikely(state == NULL)) {
return NULL;
}
state->stack = SCCalloc(1, sizeof(MimeDecStack));
if (unlikely(state->stack == NULL)) {
SCFree(state);
return NULL;
}
mimeMsg = SCCalloc(1, sizeof(MimeDecEntity));
if (unlikely(mimeMsg == NULL)) {
SCFree(state->stack);
SCFree(state);
return NULL;
}
mimeMsg->ctnt_flags |= CTNT_IS_MSG;
/* Init state */
state->msg = mimeMsg;
PushStack(state->stack);
if (state->stack->top == NULL) {
SCFree(state->stack);
SCFree(state);
return NULL;
}
state->stack->top->data = mimeMsg;
state->state_flag = HEADER_READY;
state->data = data;
state->DataChunkProcessorFunc = DataChunkProcessorFunc;
return state;
}
Actions