Browse Source

dtc: Fix memory leak in character literal parsing

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@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Gabriel Smith 8 years ago committed by David Gibson
parent
commit
f88865469b
  1. 16
      dtc-lexer.l

16
dtc-lexer.l

@ -189,16 +189,16 @@ static void lexical_error(const char *fmt, ...); @@ -189,16 +189,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;
}


Loading…
Cancel
Save