aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-10-03 03:29:38 -0500
committerRob Landley <rob@landley.net>2017-10-03 03:29:38 -0500
commit78289203031afc23585035c362beec10db54958d (patch)
treec887b848b776747f019dc1951a0c9cc74a785751
parentb89af5ed5c95ebe0466830d90eedd430593a3584 (diff)
downloadtoybox-0.7.5.tar.gz
Workaround from Patrick Oppenlander for a bug in config2help.h that resulted0.7.5
in segfaults on newer toolchains. (That entire section is due for a rewrite.)
-rw-r--r--scripts/config2help.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/config2help.c b/scripts/config2help.c
index 575b7b8a..d2389392 100644
--- a/scripts/config2help.c
+++ b/scripts/config2help.c
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
// entry until we run out of matching pairs.
for (;;) {
struct symbol *throw = 0, *catch;
- char *this, *that, *cusage, *tusage, *name;
+ char *this, *that, *cusage, *tusage, *name = 0;
int len;
// find a usage: name and collate all enabled entries with that name
@@ -270,16 +270,18 @@ int main(int argc, char *argv[])
if (catch->enabled != 1) continue;
if (catch->help && (that = keyword("usage:", catch->help->data))) {
struct double_list *cfrom, *tfrom, *anchor;
- char *try, **cdashlines, **tdashlines;
+ char *try, **cdashlines, **tdashlines, *usage;
int clen, tlen;
// Align usage: lines, finding a matching pair so we can suck help
// text out of throw into catch, copying from this to that
- if (!throw) name = that;
+ if (!throw) usage = that;
else if (strncmp(name, that, len) || !isspace(that[len])) continue;
catch->enabled++;
while (!isspace(*that) && *that) that++;
- if (!throw) len = that-name;
+ if (!throw) len = that-usage;
+ free(name);
+ name = strndup(usage, len);
that = skip_spaces(that);
if (!throw) {
throw = catch;