Project

General

Profile

Actions

Bug #1359

closed

memory leak

Added by wei xuan almost 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

fix up the memory leak in ans1 match


Files

util-decode-asn1.c (23 KB) util-decode-asn1.c for memory leak of ans1 match wei xuan, 01/09/2015 08:12 PM
Actions #1

Updated by wei xuan almost 10 years ago

there are two memory leak in SCAsn1CtxDestroy
the first:
the malloc memory in SCAsn1CtxNew in util-decode-asn1.c

ac->asn1_stack = SCMalloc(sizeof(Asn1Node *) * asn1_max_frames_config);

but when destory in SCAsn1CtxDestroy in util-decode-asn1.c, only free ac
SCFree(ac);

so the memory of asn1_stack will leak

the second:
in SCAsn1Decode of SCAsn1Decode
if (SCAsn1CtxNewFrame(ac, node_id) == NULL)
break;

ac->cur_frame = node_id;
this code in while, for example, if the while run twice, malloc two node, the cur_frame is only 1

but SCAsn1CtxDestroy in util-decode-asn1.c
for (; i < ac->cur_frame; i++) {
Asn1Node *node = ASN1CTX_GET_NODE(ac, i);
if (node != NULL) {
SCFree(node);
}
}

when we free the node in SCAsn1Decode , the last node we don't free, so memory leak here.

repair them,
the frist memory leak, should add
SCFree(ac->asn1_stack)
the second memory leak, should modified i < ac->cur_frame to i <= ac->cur_frame

Actions #2

Updated by Victor Julien over 9 years ago

  • Status changed from New to Assigned
  • Assignee changed from wei xuan to Jason Ish
  • Priority changed from High to Normal
  • Target version set to 3.0RC1

Jason can you check this in master and 2.0.8? If stable is affected we'll need a separate ticket for that.

Actions #3

Updated by Victor Julien about 9 years ago

  • Target version changed from 3.0RC1 to 70
Actions #4

Updated by Victor Julien almost 9 years ago

  • Priority changed from Normal to High
Actions #5

Updated by Jason Ish almost 9 years ago

  • Status changed from Assigned to Resolved
Actions #6

Updated by Victor Julien almost 9 years ago

  • Status changed from Resolved to Closed
  • Target version changed from 70 to 3.0.1RC1
Actions

Also available in: Atom PDF