All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Kevin Cernekee <cernekee@chromium.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 2/2 conntrack-tools] conntrackd: config: Free strdup()ed tokens
Date: Wed, 1 Feb 2017 18:03:57 +0100	[thread overview]
Message-ID: <20170201170357.GA5052@salvia> (raw)
In-Reply-To: <20170127203847.10785-2-cernekee@chromium.org>

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

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.

[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 1169 bytes --]

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}		;

  reply	other threads:[~2017-02-01 17:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 20:38 [PATCH 1/2 conntrack-tools] conntrackd: cthelper: Free pktb after use Kevin Cernekee
2017-01-27 20:38 ` [PATCH 2/2 conntrack-tools] conntrackd: config: Free strdup()ed tokens Kevin Cernekee
2017-02-01 17:03   ` Pablo Neira Ayuso [this message]
2017-02-01 17:04 ` [PATCH 1/2 conntrack-tools] conntrackd: cthelper: Free pktb after use Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170201170357.GA5052@salvia \
    --to=pablo@netfilter.org \
    --cc=cernekee@chromium.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.