* [PATCH] dtc: Fix memory leak in character literal parsing @ 2016-12-11 20:13 Gabriel Smith [not found] ` <1481487196-20830-1-git-send-email-ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Gabriel Smith @ 2016-12-11 20:13 UTC (permalink / raw) To: David Gibson, Jon Loeliger Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Gabriel Smith The data struct used for parsing character literals was never freed resulting in a few bytes leaked for every character. Signed-off-by: Gabriel Smith <ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- dtc-lexer.l | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dtc-lexer.l b/dtc-lexer.l index 790fbf6..f252ab9 100644 --- a/dtc-lexer.l +++ b/dtc-lexer.l @@ -184,16 +184,16 @@ static void lexical_error(const char *fmt, ...); if (d.len == 1) { lexical_error("Empty character literal"); yylval.integer = 0; - return DT_CHAR_LITERAL; - } - - yylval.integer = (unsigned char)d.val[0]; + } else { + yylval.integer = (unsigned char)d.val[0]; - if (d.len > 2) - lexical_error("Character literal has %d" - " characters instead of 1", - d.len - 1); + if (d.len > 2) + lexical_error("Character literal has %d" + " characters instead of 1", + d.len - 1); + } + data_free(d); return DT_CHAR_LITERAL; } -- 2.7.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
[parent not found: <1481487196-20830-1-git-send-email-ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] dtc: Fix memory leak in character literal parsing [not found] ` <1481487196-20830-1-git-send-email-ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-12-11 23:34 ` David Gibson 0 siblings, 0 replies; 2+ messages in thread From: David Gibson @ 2016-12-11 23:34 UTC (permalink / raw) To: Gabriel Smith; +Cc: Jon Loeliger, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1438 bytes --] On Sun, Dec 11, 2016 at 03:13:16PM -0500, Gabriel Smith wrote: > The data struct used for parsing character literals was never freed > resulting in a few bytes leaked for every character. > > Signed-off-by: Gabriel Smith <ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Nice catch. Merged and pushed. > --- > dtc-lexer.l | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/dtc-lexer.l b/dtc-lexer.l > index 790fbf6..f252ab9 100644 > --- a/dtc-lexer.l > +++ b/dtc-lexer.l > @@ -184,16 +184,16 @@ static void lexical_error(const char *fmt, ...); > if (d.len == 1) { > lexical_error("Empty character literal"); > yylval.integer = 0; > - return DT_CHAR_LITERAL; > - } > - > - yylval.integer = (unsigned char)d.val[0]; > + } else { > + yylval.integer = (unsigned char)d.val[0]; > > - if (d.len > 2) > - lexical_error("Character literal has %d" > - " characters instead of 1", > - d.len - 1); > + if (d.len > 2) > + lexical_error("Character literal has %d" > + " characters instead of 1", > + d.len - 1); > + } > > + data_free(d); > return DT_CHAR_LITERAL; > } > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-11 23:34 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-11 20:13 [PATCH] dtc: Fix memory leak in character literal parsing Gabriel Smith [not found] ` <1481487196-20830-1-git-send-email-ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-12-11 23:34 ` David Gibson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).