source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Fix two memory leaks in makewhatis -n: 1.
@ 2014-05-07 15:10 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-05-07 15:10 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.146 -r1.147
--- mandocdb.c
+++ mandocdb.c
@@ -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
 	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) {
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-07 15:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 15:10 mdocml: Fix two memory leaks in makewhatis -n: 1 schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).