aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-10-22 21:03:43 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-10-22 21:03:43 +0000
commit9712be0c6ab0aa2d1baa5449bf191e975946ebdb (patch)
tree528b0941a838716f4ab94b382a980225fd544706 /main.c
parent56bf7e8b9228994f0a7e6486d7dc6ce9ff9fb51d (diff)
downloadmandoc-9712be0c6ab0aa2d1baa5449bf191e975946ebdb.tar.gz
mandoc-9712be0c6ab0aa2d1baa5449bf191e975946ebdb.tar.zst
mandoc-9712be0c6ab0aa2d1baa5449bf191e975946ebdb.zip
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@
Diffstat (limited to 'main.c')
-rw-r--r--main.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/main.c b/main.c
index 39c8946e..b03ba073 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.251 2015/10/20 02:01:31 schwarze Exp $ */
+/* $Id: main.c,v 1.252 2015/10/22 21:03:43 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -466,21 +466,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();