On Fri, Jan 27, 2017 at 12:38:47PM -0800, Kevin Cernekee wrote: > This frees T_IP, T_PATH_VAL, and T_STRING tokens. They were being flagged > by valgrind as memory leaks. Thanks Kevin. I think we can just remove the strdup() from the lexer, given that we always copy these strings in the parser. See patch attached.
diff --git a/src/read_config_lex.l b/src/read_config_lex.l index 0282534e7291..a378269491f1 100644 --- a/src/read_config_lex.l +++ b/src/read_config_lex.l @@ -141,9 +141,9 @@ notrack [N|n][O|o][T|t][R|r][A|a][C|c][K|k] {is_off} { return T_OFF; } {integer} { yylval.val = atoi(yytext); return T_NUMBER; } {signed_integer} { yylval.val = atoi(yytext); return T_SIGNED_NUMBER; } -{ip4} { yylval.string = strdup(yytext); return T_IP; } -{ip6} { yylval.string = strdup(yytext); return T_IP; } -{path} { yylval.string = strdup(yytext); return T_PATH_VAL; } +{ip4} { yylval.string = yytext; return T_IP; } +{ip6} { yylval.string = yytext; return T_IP; } +{path} { yylval.string = yytext; return T_PATH_VAL; } {alarm} { return T_ALARM; } {persistent} { dlog(LOG_WARNING, "Now `persistent' mode " "is called `alarm'. Please, update " @@ -155,7 +155,7 @@ notrack [N|n][O|o][T|t][R|r][A|a][C|c][K|k] "your conntrackd.conf file.\n"); return T_FTFW; } {notrack} { return T_NOTRACK; } -{string} { yylval.string = strdup(yytext); return T_STRING; } +{string} { yylval.string = yytext; return T_STRING; } {comment} ; {ws} ;