aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2005-03-06 01:05:36 +0000
committerMatthias Andree <matthias.andree@gmx.de>2005-03-06 01:05:36 +0000
commita3b0cfbc739c96d2d5608c6acee78786c4e5232c (patch)
tree132ae2352ac82a2e4c85489031874d4c33532050
parentbcb6d768072635acac76f53d5f57178ff244a11f (diff)
downloadfetchmail-a3b0cfbc739c96d2d5608c6acee78786c4e5232c.tar.gz
fetchmail-a3b0cfbc739c96d2d5608c6acee78786c4e5232c.tar.bz2
fetchmail-a3b0cfbc739c96d2d5608c6acee78786c4e5232c.zip
Fix memory leak.
svn path=/trunk/; revision=4018
-rw-r--r--rcfile_l.l33
1 files changed, 15 insertions, 18 deletions
diff --git a/rcfile_l.l b/rcfile_l.l
index b50ac617..7cd26d03 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -31,20 +31,18 @@ int prc_lineno = 1;
%%
\"[^\"]*\" {
- char buf[MSGBUFSIZE];
-
yytext[strlen(yytext)-1] = '\0';
- escapes(yytext+1, buf);
- yylval.sval = (char *) xstrdup(buf);
+ escapes(yytext+1, yytext);
+ yyleng = strlen(yytext);
+ yylval.sval = yytext;
SETSTATE(0);
return STRING;
}
\'[^\']*\' {
- char buf[MSGBUFSIZE];
-
yytext[strlen(yytext)-1] = '\0';
- escapes(yytext+1, buf);
- yylval.sval = (char *) xstrdup(buf);
+ escapes(yytext+1, yytext);
+ yyleng = strlen(yytext);
+ yylval.sval = yytext;
SETSTATE(0);
return STRING;
}
@@ -52,10 +50,9 @@ int prc_lineno = 1;
"*" { BEGIN(0); return WILDCARD; }
<NAME>[^=;:, \t\r\n]+ {
- char buf[MSGBUFSIZE];
-
- escapes(yytext, buf);
- yylval.sval = (char *) xstrdup(buf);
+ escapes(yytext, yytext);
+ yyleng = strlen(yytext);
+ yylval.sval = yytext;
SETSTATE(0);
return STRING;
}
@@ -204,10 +201,9 @@ options {/* EMPTY */}
-?[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
[^=;:, \t\r\n]+ {
- char buf[MSGBUFSIZE];
-
- escapes(yytext, buf);
- yylval.sval = (char *) xstrdup(buf);
+ escapes(yytext, yytext);
+ yyleng = strlen(yytext);
+ yylval.sval = yytext;
return STRING;
}
@@ -216,7 +212,9 @@ options {/* EMPTY */}
%%
void escapes(cp, tp)
-/* process standard C-style escape sequences in a string */
+/* process standard C-style escape sequences in a string,
+ * this can never lengthen the output, so cp and tp may overlap as long
+ * as cp >= tp. */
const char *cp; /* source string with escapes */
char *tp; /* target buffer for digested string */
{
@@ -259,4 +257,3 @@ char *tp; /* target buffer for digested string */
}
*tp = '\0';
}
-