barebox crashes with CONFIG_CMD_MAGICVAR=y and CONFIG_CMD_MAGICVAR_HELP unset

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Thu Sep 8 12:27:52 PDT 2016


Hello,

with

	CONFIG_CMD_MAGICVAR=y
	# CONFIG_CMD_MAGICVAR_HELP is not set

calling magicvar results in

	md->description = xstrdup(description)

in line 64 of commands/magicvar.c. As CONFIG_CMD_MAGICVAR_HELP is not
set, description is NULL which makes xstrdup fail.

I fixed it here doing

-       md->description = xstrdup(description);
+       md->description = description ? xstrdup(description) : NULL;

but I can imagine other variants:

	if (IS_ENABLED(CONFIG_CMD_MAGICVAR_HELP))
		md->description = xstrdup(description);

or fixing xstrdup to not choke on NULL.

What do you prefer?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list