From: Victor Julien Date: Thu, 18 Jun 2015 13:46:28 +0000 (+0200) Subject: dce_opnum: improve memory handling on parsing error X-Git-Tag: suricata-3.0RC1~297 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5168d59770ea990a3276af83b69caad5faadeeb;p=thirdparty%2Fsuricata.git dce_opnum: improve memory handling on parsing error --- diff --git a/src/detect-dce-opnum.c b/src/detect-dce-opnum.c index 3c6e6aad67..0885666374 100644 --- a/src/detect-dce-opnum.c +++ b/src/detect-dce-opnum.c @@ -182,6 +182,13 @@ static inline DetectDceOpnumData *DetectDceOpnumArgParse(const char *arg) dor = DetectDceOpnumAllocDetectDceOpnumRange(); if (dor == NULL) goto error; + if (prev_dor == NULL) { + prev_dor = dor; + dod->range = dor; + } else { + prev_dor->next = dor; + prev_dor = dor; + } if ((hyphen_token = index(dup_str_temp, '-')) != NULL) { hyphen_token[0] = '\0'; @@ -199,20 +206,17 @@ static inline DetectDceOpnumData *DetectDceOpnumArgParse(const char *arg) if (dor->range1 > DCE_OPNUM_RANGE_MAX) goto error; - if (prev_dor == NULL) { - prev_dor = dor; - dod->range = dor; - } else { - prev_dor->next = dor; - prev_dor = dor; - } - dup_str_temp = dup_str; } dor = DetectDceOpnumAllocDetectDceOpnumRange(); if (dor == NULL) goto error; + if (prev_dor == NULL) { + dod->range = dor; + } else { + prev_dor->next = dor; + } if ( (hyphen_token = index(dup_str, '-')) != NULL) { hyphen_token[0] = '\0'; @@ -230,12 +234,6 @@ static inline DetectDceOpnumData *DetectDceOpnumArgParse(const char *arg) if (dor->range1 > DCE_OPNUM_RANGE_MAX) goto error; - if (prev_dor == NULL) { - dod->range = dor; - } else { - prev_dor->next = dor; - } - if (dup_str_head != NULL) SCFree(dup_str_head);