summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu Wang <coolwanglu@gmail.com>2013-09-21 10:37:30 +0200
committerAlbert Astals Cid <aacid@kde.org>2013-09-21 10:38:12 +0200
commitdc344b410f49410174ee902b7649ebd8c2cb0fa2 (patch)
tree74de59ce787df15e3953737da4f7bb75ee32dea2
parent1e612d331b79dabec66ad241d7ffe66674a10bc4 (diff)
pdftocairo: check file opening failure in beginDocument()
-rw-r--r--utils/pdftocairo.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 192d2957..e1fb2584 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -26,6 +26,7 @@
// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2012 Koji Otani <sho@bbr.jp>
+// Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -484,7 +485,13 @@ static void beginDocument(GooString *outputFileName, double w, double h)
if (outputFileName->cmp("fd://0") == 0)
output_file = stdout;
else
+ {
output_file = fopen(outputFileName->getCString(), "wb");
+ if (!output_file) {
+ fprintf(stderr, "Error opening output file %s\n", outputFileName->getCString());
+ exit(2);
+ }
+ }
if (ps || eps) {
#if CAIRO_HAS_PS_SURFACE