From: schwarze Date: Thu, 22 Oct 2015 21:02:55 +0000 (+0000) Subject: If no output device was allocated because no file wanted to produce output, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=da67bd1bd63e851cf3412dd5e2f14d86ca014abe;p=openbsd If no output device was allocated because no file wanted to produce output, refrain from dereferencing a NULL pointer during final deallocation. Fixing a recent regression reported by czarkoff@ --- diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 493fb8e1389..a3ff21274cd 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.159 2015/10/20 02:00:49 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.160 2015/10/22 21:02:55 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze @@ -446,21 +446,23 @@ main(int argc, char *argv[]) mparse_reset(curp.mp); } - switch (curp.outtype) { - case OUTT_HTML: - html_free(curp.outdata); - break; - case OUTT_UTF8: - case OUTT_LOCALE: - case OUTT_ASCII: - ascii_free(curp.outdata); - break; - case OUTT_PDF: - case OUTT_PS: - pspdf_free(curp.outdata); - break; - default: - break; + if (curp.outdata != NULL) { + switch (curp.outtype) { + case OUTT_HTML: + html_free(curp.outdata); + break; + case OUTT_UTF8: + case OUTT_LOCALE: + case OUTT_ASCII: + ascii_free(curp.outdata); + break; + case OUTT_PDF: + case OUTT_PS: + pspdf_free(curp.outdata); + break; + default: + break; + } } mparse_free(curp.mp); mchars_free();