summaryrefslogtreecommitdiffstats
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
commit9953b888e25942fa632d3e754daa293a4239d4c5 (patch)
tree9912c41a7c1f1bb11135b4df96e9c3fb1fc300b8
parentddefce3b76421a0191621f40623ba04fd510db65 (diff)
downloadmandoc-9953b888e25942fa632d3e754daa293a4239d4c5.tar.gz
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@
-rw-r--r--main.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/main.c b/main.c
index d2549083..8ba7da50 100644
--- a/main.c
+++ b/main.c
@@ -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();