[poppler] cpp/poppler-embedded-file.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 6 22:15:50 UTC 2020


 cpp/poppler-embedded-file.cpp |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

New commits:
commit d4be954367cb1ff6f372b74bbd8f186238ec86fc
Author: Albert Astals Cid <aacid at kde.org>
Date:   Wed Oct 7 00:08:44 2020 +0200

    cpp: Fix crashes in embedded file handling on broken files
    
    Fixes #966

diff --git a/cpp/poppler-embedded-file.cpp b/cpp/poppler-embedded-file.cpp
index 4ce03950..ab873de2 100644
--- a/cpp/poppler-embedded-file.cpp
+++ b/cpp/poppler-embedded-file.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009-2011, Pino Toscano <pino at kde.org>
  * Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
- * Copyright (C) 2018 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2018, 2020 Albert Astals Cid <aacid at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -96,7 +96,8 @@ ustring embedded_file::description() const
  */
 int embedded_file::size() const
 {
-    return d->file_spec->getEmbeddedFile()->size();
+    const EmbFile *ef = d->file_spec->getEmbeddedFile();
+    return ef ? ef->size() : -1;
 }
 
 /**
@@ -105,7 +106,8 @@ int embedded_file::size() const
  */
 time_type embedded_file::modification_date() const
 {
-    const GooString *goo = d->file_spec->getEmbeddedFile()->modDate();
+    const EmbFile *ef = d->file_spec->getEmbeddedFile();
+    const GooString *goo = ef ? ef->modDate() : nullptr;
     return goo ? dateStringToTime(goo) : time_type(-1);
 }
 
@@ -115,7 +117,8 @@ time_type embedded_file::modification_date() const
  */
 time_type embedded_file::creation_date() const
 {
-    const GooString *goo = d->file_spec->getEmbeddedFile()->createDate();
+    const EmbFile *ef = d->file_spec->getEmbeddedFile();
+    const GooString *goo = ef ? ef->createDate() : nullptr;
     return goo ? dateStringToTime(goo) : time_type(-1);
 }
 
@@ -124,7 +127,8 @@ time_type embedded_file::creation_date() const
  */
 byte_array embedded_file::checksum() const
 {
-    const GooString *cs = d->file_spec->getEmbeddedFile()->checksum();
+    const EmbFile *ef = d->file_spec->getEmbeddedFile();
+    const GooString *cs = ef ? ef->checksum() : nullptr;
     if (!cs) {
         return byte_array();
     }
@@ -141,7 +145,8 @@ byte_array embedded_file::checksum() const
  */
 std::string embedded_file::mime_type() const
 {
-    const GooString *goo = d->file_spec->getEmbeddedFile()->mimeType();
+    const EmbFile *ef = d->file_spec->getEmbeddedFile();
+    const GooString *goo = ef ? ef->mimeType() : nullptr;
     return goo ? std::string(goo->c_str()) : std::string();
 }
 
@@ -155,7 +160,8 @@ byte_array embedded_file::data() const
     if (!is_valid()) {
         return byte_array();
     }
-    Stream *stream = d->file_spec->getEmbeddedFile()->stream();
+    EmbFile *ef = d->file_spec->getEmbeddedFile();
+    Stream *stream = ef ? ef->stream() : nullptr;
     if (!stream) {
         return byte_array();
     }


More information about the poppler mailing list