devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Smith <ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: David Gibson
	<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>,
	Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Gabriel Smith <ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH] dtc: Fix memory leak in character literal parsing
Date: Sun, 11 Dec 2016 15:13:16 -0500	[thread overview]
Message-ID: <1481487196-20830-1-git-send-email-ga29smith@gmail.com> (raw)

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

             reply	other threads:[~2016-12-11 20:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11 20:13 Gabriel Smith [this message]
     [not found] ` <1481487196-20830-1-git-send-email-ga29smith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-11 23:34   ` [PATCH] dtc: Fix memory leak in character literal parsing David Gibson

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=1481487196-20830-1-git-send-email-ga29smith@gmail.com \
    --to=ga29smith-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.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 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).