From a67cb1319f53fa68012a23d6ca45279c6bc627f8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 19 Sep 2007 21:23:09 +0200 Subject: 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" for inital reporting and to Gabriel C for the backtrace that helped me locating the bug. Signed-off-by: Sam Ravnborg --- scripts/kconfig/util.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'scripts/kconfig/util.c') diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index e3f28b9d59f4..e1cad924c0a4 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -84,12 +84,15 @@ void str_free(struct gstr *gs) /* Append to growable string */ void str_append(struct gstr *gs, const char *s) { - size_t l = strlen(gs->s) + strlen(s) + 1; - if (l > gs->len) { - gs->s = realloc(gs->s, l); - gs->len = l; + size_t l; + if (s) { + l = strlen(gs->s) + strlen(s) + 1; + 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 */ -- cgit v1.2.3