changeset 136:59680a727e9d

Improve previous. Just in case we ever crash and reach cleanup() while processing an -include foo option, take the array entry for it out of the array to make sure it doesn't get freed twice. This case shouldn't be reachable, but it's better to be safe.
author David A. Holland
date Tue, 09 Jul 2013 13:38:43 -0400
parents eaae8014a94a
children 0816803b22d1
files main.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Tue Jul 09 13:35:40 2013 -0400
+++ b/main.c	Tue Jul 09 13:38:43 2013 -0400
@@ -268,7 +268,9 @@
 	num = array_num(&commandline_files);
 	for (i=0; i<num; i++) {
 		cf = array_get(&commandline_files, i);
-		dofree(cf, sizeof(*cf));
+		if (cf != NULL) {
+			dofree(cf, sizeof(*cf));
+		}
 	}
 	array_setsize(&commandline_files, 0);
 
@@ -313,6 +315,7 @@
 	num = array_num(&commandline_files);
 	for (i=0; i<num; i++) {
 		cf = array_get(&commandline_files, i);
+		array_set(&commandline_files, i, NULL);
 		if (cf->suppress_output) {
 			save = mode.do_output;
 			mode.do_output = false;