Skip to content

Commit

Permalink
kconfig: Don't leak 'option' arguments during parsing
Browse files Browse the repository at this point in the history
The following strings would leak before this change:

	- option env="LEAKED"
	- option defconfig_list="LEAKED"

These come in the form of T_WORD tokens and are always allocated on the
heap in zconf.l. Free them.

Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

	LEAK SUMMARY:
	   definitely lost: 344,616 bytes in 14,355 blocks
	   ...

Summary after the fix:

	LEAK SUMMARY:
	   definitely lost: 344,568 bytes in 14,352 blocks
	   ...

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
  • Loading branch information
Ulf Magnusson authored and Masahiro Yamada committed Jan 10, 2018
1 parent 24161a6 commit bc28fe1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/kconfig/zconf.y
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ symbol_option_list:
| symbol_option_list T_WORD symbol_option_arg
{
const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
if (id && id->flags & TF_OPTION)
if (id && id->flags & TF_OPTION) {
menu_add_option(id->token, $3);
free($3);
}
else
zconfprint("warning: ignoring unknown option %s", $2);
free($2);
Expand Down

0 comments on commit bc28fe1

Please sign in to comment.