[PATCH] possible memleaks
Urs Janßen <[email protected]> Thu, 13 May 2010 01:43:08 +0200
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
The patch below should fix some possible memleaks on "broken" servers which do have dublicated overview fields. i.e.: | > list overview.fmt | < 215 Order of fields in overview database | < Subject: | < From: | < Date: | < Message-ID: | < References: | < Bytes: | < Lines: | < Xref:full | < injection-info:full | < keywords:full | < Path:full | < Xref:full | < User-Agent:full | < . | > group trigofacile.test | < 211 398 7 450 trigofacile.test | > over 450 | < 224 Overview information for 450 follows | < 450 Re: newsfeeds O =?iso-8859-15?Q?Julien_=C9LIE?= <[email protected]> Sat, 8 May 2010 00:05:30 +0200 <[email protected]> <[email protected]> 1085 1 Xref: news.trigofacile.com trigofacile.test:450 Injection-Info: news.trigofacile.com; posting-host="aaubervilliers-151-1-18-59.w83-114.abo.wanadoo.fr:83.114.137.59"; logging-data="2024"; mail-complaints-to="[email protected]" Path: .POSTED.aaubervilliers-151-1-18-59.w83-114.abo.wanadoo.fr!not-for-mail Xref: news.trigofacile.com trigofacile.test:450 | < . Xref is given twice here. I don't know which occurence should be used (first or last). The current code is last match counts and the patch below just fixes the possible memleaks. First match counts might be more usefull. === modified file 'src/art.c' --- src/art.c 2010-03-19 23:11:02 +0000 +++ src/art.c 2010-05-12 22:17:10 +0000 @@ -1608,9 +1608,10 @@ /* madatory fields */ if (ofmt[count].type == OVER_T_STRING) { if (!strcasecmp(ofmt[count].name, "Subject:")) { - if (*ptr) + if (*ptr) { + FreeIfNeeded(art->subject); /* if field is listed more than once in overview.fmt */ art->subject = hash_str(eat_re(eat_tab(convert_to_printable(rfc1522_decode(ptr))), FALSE)); - else { + } else { art->subject = hash_str(""); #ifdef DEBUG if (debug & DEBUG_NNTP) @@ -1622,6 +1623,7 @@ if (!strcasecmp(ofmt[count].name, "From:")) { if (*ptr) { + FreeIfNeeded(art->from); /* if field is listed more than once in overview.fmt */ art->gnksa_code = parse_from(ptr, art_from_addr, art_full_name); art->from = hash_str(buffer_to_ascii(art_from_addr)); if (*art_full_name) @@ -1646,9 +1648,10 @@ } if (!strcasecmp(ofmt[count].name, "Message-ID:")) { - if (*ptr) + if (*ptr) { + FreeIfNeeded(art->msgid); /* if field is listed more than once in overview.fmt */ art->msgid = my_strdup(ptr); - else { + } else { art->msgid = NULL; #ifdef DEBUG if (debug & DEBUG_NNTP) @@ -1659,9 +1662,10 @@ } if (!strcasecmp(ofmt[count].name, "References:")) { - if (*ptr) + if (*ptr) { + FreeIfNeeded(art->refs); /* if field is listed more than once in overview.fmt */ art->refs = my_strdup(ptr); - else + } else art->refs = NULL; continue; } @@ -1782,8 +1786,10 @@ /* optional fields */ if (ofmt[count].type == OVER_T_FSTRING) { if (!strcasecmp(ofmt[count].name, "Xref:")) { - if ((q = parse_header(ptr, "Xref", FALSE, FALSE)) != NULL) + if ((q = parse_header(ptr, "Xref", FALSE, FALSE)) != NULL) { + FreeIfNeeded(art->xref); /* if field is listed more than once in overview.fmt */ art->xref = my_strdup(q); + } #ifdef DEBUG else { if (debug & DEBUG_NNTP)