diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-05-07 15:10:36 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-05-07 15:10:36 +0000 |
commit | 9530f39e422a0f12346c8786e84e0137349ed81a (patch) | |
tree | c32e892fc796670d4783a640928f2487a23cf7aa /mandocdb.c | |
parent | b9c525e48989511fbf504fe170eb6ba6231845fb (diff) | |
download | mandoc-9530f39e422a0f12346c8786e84e0137349ed81a.tar.gz |
Fix two memory leaks in makewhatis -n:
1. As found by nigel@, names_check() requires database access.
2. Do not leak names and strings in -n mode.
Diffstat (limited to 'mandocdb.c')
-rw-r--r-- | mandocdb.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -512,7 +512,7 @@ main(int argc, char *argv[]) goto out; mpages_merge(mc, mp); - if (warnings && + if (warnings && !nodb && ! (MPARSE_QUICK & mparse_options)) names_check(); dbclose(0); @@ -1996,6 +1996,18 @@ dbadd(struct mpage *mpage, struct mchars *mc) mlink = mpage->mlinks; if (nodb) { + for (key = ohash_first(&names, &slot); NULL != key; + key = ohash_next(&names, &slot)) { + if (key->rendered != key->key) + free(key->rendered); + free(key); + } + for (key = ohash_first(&strings, &slot); NULL != key; + key = ohash_next(&strings, &slot)) { + if (key->rendered != key->key) + free(key->rendered); + free(key); + } if (0 == debug) return; while (NULL != mlink) { |