comparison main.c @ 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
comparison
equal deleted inserted replaced
135:eaae8014a94a 136:59680a727e9d
266 struct commandline_file *cf; 266 struct commandline_file *cf;
267 267
268 num = array_num(&commandline_files); 268 num = array_num(&commandline_files);
269 for (i=0; i<num; i++) { 269 for (i=0; i<num; i++) {
270 cf = array_get(&commandline_files, i); 270 cf = array_get(&commandline_files, i);
271 dofree(cf, sizeof(*cf)); 271 if (cf != NULL) {
272 dofree(cf, sizeof(*cf));
273 }
272 } 274 }
273 array_setsize(&commandline_files, 0); 275 array_setsize(&commandline_files, 0);
274 276
275 array_cleanup(&commandline_files); 277 array_cleanup(&commandline_files);
276 } 278 }
311 bool save = false; 313 bool save = false;
312 314
313 num = array_num(&commandline_files); 315 num = array_num(&commandline_files);
314 for (i=0; i<num; i++) { 316 for (i=0; i<num; i++) {
315 cf = array_get(&commandline_files, i); 317 cf = array_get(&commandline_files, i);
318 array_set(&commandline_files, i, NULL);
316 if (cf->suppress_output) { 319 if (cf->suppress_output) {
317 save = mode.do_output; 320 save = mode.do_output;
318 mode.do_output = false; 321 mode.do_output = false;
319 file_readquote(&cf->where, cf->name); 322 file_readquote(&cf->where, cf->name);
320 mode.do_output = save; 323 mode.do_output = save;