aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/util.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2007-09-19 15:23:09 -0400
committerSam Ravnborg <sam@neptun.(none)>2007-10-12 15:15:32 -0400
commita67cb1319f53fa68012a23d6ca45279c6bc627f8 (patch)
tree36a9ca55dd8180ca3583d4dbd22ed8c72fb1f04a /scripts/kconfig/util.c
parent48874077ddd6c0c444758059af2cf77c10204ece (diff)
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: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/util.c')
-rw-r--r--scripts/kconfig/util.c13
1 files changed, 8 insertions, 5 deletions
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)
84/* Append to growable string */ 84/* Append to growable string */
85void str_append(struct gstr *gs, const char *s) 85void str_append(struct gstr *gs, const char *s)
86{ 86{
87 size_t l = strlen(gs->s) + strlen(s) + 1; 87 size_t l;
88 if (l > gs->len) { 88 if (s) {
89 gs->s = realloc(gs->s, l); 89 l = strlen(gs->s) + strlen(s) + 1;
90 gs->len = l; 90 if (l > gs->len) {
91 gs->s = realloc(gs->s, l);
92 gs->len = l;
93 }
94 strcat(gs->s, s);
91 } 95 }
92 strcat(gs->s, s);
93} 96}
94 97
95/* Append printf formatted string to growable string */ 98/* Append printf formatted string to growable string */