From 97939338caf927c795ebb780aac3e38f213d3e7c Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 13 Nov 2011 00:53:13 +0000 Subject: Fix two crashes that occur when walking very large (i.e. real-world) trees: 1) Avoid excessive, needless recursion, lest you overflow the stack; 2) Close all dir file descriptors, lest you run out of descriptors. ok kristaps@ --- mandocdb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'mandocdb.c') diff --git a/mandocdb.c b/mandocdb.c index d9f57416..7e2b4a54 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.6 2011/09/17 13:54:27 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.7 2011/11/13 00:53:13 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -1168,10 +1168,9 @@ pman_node(MAN_ARGS) } } - if (pman_node(hash, buf, dbuf, n->child)) - return(1); - if (pman_node(hash, buf, dbuf, n->next)) - return(1); + for (n = n->child; n; n = n->next) + if (pman_node(hash, buf, dbuf, n)) + return(1); return(0); } @@ -1276,6 +1275,7 @@ ofile_dirbuild(const char *dir, int verb, struct of **of) } } + closedir(d); return(1); } -- cgit v1.2.3-56-ge451