summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-12-10 22:18:20 +0000
committerschwarze <schwarze@openbsd.org>2011-12-10 22:18:20 +0000
commitfe521982cdd85a89750eb25c01b89e482762f871 (patch)
treedcb4b0e74c377629fc015ac48642a1f580e1597f
parentAvoid leaking index records: (diff)
downloadwireguard-openbsd-fe521982cdd85a89750eb25c01b89e482762f871.tar.xz
wireguard-openbsd-fe521982cdd85a89750eb25c01b89e482762f871.zip
Bugfixes from kristaps@:
(1) Always show architecture-independent manuals, even when an architecture is specified on the command line. (2) Do not leak memory when a manual is skipped because it's the wrong section or architecture.
-rw-r--r--usr.bin/mandoc/apropos_db.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/mandoc/apropos_db.c b/usr.bin/mandoc/apropos_db.c
index b3c32e2c955..ec1be3164e3 100644
--- a/usr.bin/mandoc/apropos_db.c
+++ b/usr.bin/mandoc/apropos_db.c
@@ -1,4 +1,4 @@
-/* $Id: apropos_db.c,v 1.13 2011/12/03 22:47:27 schwarze Exp $ */
+/* $Id: apropos_db.c,v 1.14 2011/12/10 22:18:20 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -530,13 +530,16 @@ single_search(struct rectree *tree, const struct opts *opts,
if (opts->cat && strcasecmp(opts->cat, r.res.cat))
continue;
- if (opts->arch && strcasecmp(opts->arch, r.res.arch))
- continue;
+
+ if (opts->arch && *r.res.arch)
+ if (strcasecmp(opts->arch, r.res.arch))
+ continue;
tree->node = rs = mandoc_realloc
(rs, (tree->len + 1) * sizeof(struct rec));
memcpy(&rs[tree->len], &r, sizeof(struct rec));
+ memset(&r, 0, sizeof(struct rec));
rs[tree->len].matches =
mandoc_calloc(terms, sizeof(int));
@@ -552,7 +555,6 @@ single_search(struct rectree *tree, const struct opts *opts,
} else
root = tree->len;
- memset(&r, 0, sizeof(struct rec));
tree->len++;
}
@@ -560,6 +562,7 @@ single_search(struct rectree *tree, const struct opts *opts,
(*idx->close)(idx);
free(buf);
+ recfree(&r);
return(1 == ch);
}