提交 a67cb131 编写于 作者: S Sam Ravnborg 提交者: Sam Ravnborg

kconfig: fix segv fault in menuconfig

With specific configurations requesting help for certain
menu lines caused menuconfig to crash.
This was tracked down to a null pointer bug.
Thanks to "Miles Lane" <miles.lane@gmail.com> for inital reporting
and to Gabriel C <nix.or.die@googlemail.com> for the backtrace
that helped me locating the bug.
Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
上级 48874077
...@@ -357,8 +357,9 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym) ...@@ -357,8 +357,9 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym)
bool hit; bool hit;
struct property *prop; struct property *prop;
str_printf(r, "Symbol: %s [=%s]\n", sym->name, if (sym && sym->name)
sym_get_string_value(sym)); str_printf(r, "Symbol: %s [=%s]\n", sym->name,
sym_get_string_value(sym));
for_all_prompts(sym, prop) for_all_prompts(sym, prop)
get_prompt_str(r, prop); get_prompt_str(r, prop);
hit = false; hit = false;
......
...@@ -84,12 +84,15 @@ void str_free(struct gstr *gs) ...@@ -84,12 +84,15 @@ void str_free(struct gstr *gs)
/* Append to growable string */ /* Append to growable string */
void str_append(struct gstr *gs, const char *s) void str_append(struct gstr *gs, const char *s)
{ {
size_t l = strlen(gs->s) + strlen(s) + 1; size_t l;
if (l > gs->len) { if (s) {
gs->s = realloc(gs->s, l); l = strlen(gs->s) + strlen(s) + 1;
gs->len = l; if (l > gs->len) {
gs->s = realloc(gs->s, l);
gs->len = l;
}
strcat(gs->s, s);
} }
strcat(gs->s, s);
} }
/* Append printf formatted string to growable string */ /* Append printf formatted string to growable string */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册