Project

General

Profile

Actions

Bug #1359

closed
WX JI

memory leak

Bug #1359: memory leak

Added by wei xuan over 11 years ago. Updated about 10 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

WX Updated by wei xuan over 11 years ago Actions #1

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

VJ Updated by Victor Julien almost 11 years ago Actions #2

  • 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.

VJ Updated by Victor Julien over 10 years ago Actions #3

  • Target version changed from 3.0RC1 to 70

VJ Updated by Victor Julien about 10 years ago Actions #4

  • Priority changed from Normal to High

JI Updated by Jason Ish about 10 years ago Actions #5

  • Status changed from Assigned to Resolved

VJ Updated by Victor Julien about 10 years ago Actions #6

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

Also available in: PDF Atom