summaryrefslogtreecommitdiff
path: root/utils/pdfdetach.cc
diff options
context:
space:
mode:
authorAdam Reichold <adam.reichold@t-online.de>2018-11-06 09:13:41 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2018-11-06 14:21:40 +0000
commit77a30e94d96220d7e22dff5b3f0a7f296f01b118 (patch)
tree5f1ed97f1c6279eeaf27482604a52ad029e8df5b /utils/pdfdetach.cc
parent6912e06d9ab19ba28991b5cab3319d61d856bd6d (diff)
pdfdetach: Check for valid embedded file before trying to save it.
Closes #661
Diffstat (limited to 'utils/pdfdetach.cc')
-rw-r--r--utils/pdfdetach.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/utils/pdfdetach.cc b/utils/pdfdetach.cc
index 846584a4..a8720c64 100644
--- a/utils/pdfdetach.cc
+++ b/utils/pdfdetach.cc
@@ -251,7 +251,12 @@ int main(int argc, char *argv[]) {
}
*p = '\0';
- if (!fileSpec->getEmbeddedFile()->save(path)) {
+ auto *embFile = fileSpec->getEmbeddedFile();
+ if (!embFile || !embFile->isOk()) {
+ exitCode = 3;
+ goto err2;
+ }
+ if (!embFile->save(path)) {
error(errIO, -1, "Error saving embedded file as '{0:s}'", p);
exitCode = 2;
goto err2;
@@ -296,7 +301,12 @@ int main(int argc, char *argv[]) {
p = path;
}
- if (!fileSpec->getEmbeddedFile()->save(p)) {
+ auto *embFile = fileSpec->getEmbeddedFile();
+ if (!embFile || !embFile->isOk()) {
+ exitCode = 3;
+ goto err2;
+ }
+ if (!embFile->save(p)) {
error(errIO, -1, "Error saving embedded file as '{0:s}'", p);
exitCode = 2;
goto err2;