|
|
396e5c |
From 614514f577bbe676f736afcd8065892df8391315 Mon Sep 17 00:00:00 2001
|
|
|
396e5c |
From: Marek Kasik <mkasik@redhat.com>
|
|
|
396e5c |
Date: Fri, 20 Apr 2018 11:38:13 +0200
|
|
|
396e5c |
Subject: [PATCH] Fix crash on missing embedded file
|
|
|
396e5c |
|
|
|
396e5c |
Check whether an embedded file is actually present in the PDF
|
|
|
396e5c |
and show warning in that case.
|
|
|
396e5c |
|
|
|
396e5c |
https://bugs.freedesktop.org/show_bug.cgi?id=106137
|
|
|
396e5c |
https://gitlab.freedesktop.org/poppler/poppler/issues/236
|
|
|
396e5c |
---
|
|
|
396e5c |
glib/poppler-attachment.cc | 26 +++++++++++++++++---------
|
|
|
396e5c |
glib/poppler-document.cc | 3 ++-
|
|
|
396e5c |
2 files changed, 19 insertions(+), 10 deletions(-)
|
|
|
396e5c |
|
|
|
396e5c |
diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
|
|
|
396e5c |
index c6502e9d..11ba5bb5 100644
|
|
|
396e5c |
--- a/glib/poppler-attachment.cc
|
|
|
396e5c |
+++ b/glib/poppler-attachment.cc
|
|
|
396e5c |
@@ -111,17 +111,25 @@ _poppler_attachment_new (FileSpec *emb_file)
|
|
|
396e5c |
attachment->description = _poppler_goo_string_to_utf8 (emb_file->getDescription ());
|
|
|
396e5c |
|
|
|
396e5c |
embFile = emb_file->getEmbeddedFile();
|
|
|
396e5c |
- attachment->size = embFile->size ();
|
|
|
396e5c |
+ if (embFile != NULL && embFile->streamObject()->isStream())
|
|
|
396e5c |
+ {
|
|
|
396e5c |
+ attachment->size = embFile->size ();
|
|
|
396e5c |
|
|
|
396e5c |
- if (embFile->createDate ())
|
|
|
396e5c |
- _poppler_convert_pdf_date_to_gtime (embFile->createDate (), (time_t *)&attachment->ctime);
|
|
|
396e5c |
- if (embFile->modDate ())
|
|
|
396e5c |
- _poppler_convert_pdf_date_to_gtime (embFile->modDate (), (time_t *)&attachment->mtime);
|
|
|
396e5c |
+ if (embFile->createDate ())
|
|
|
396e5c |
+ _poppler_convert_pdf_date_to_gtime (embFile->createDate (), (time_t *)&attachment->ctime);
|
|
|
396e5c |
+ if (embFile->modDate ())
|
|
|
396e5c |
+ _poppler_convert_pdf_date_to_gtime (embFile->modDate (), (time_t *)&attachment->mtime);
|
|
|
396e5c |
|
|
|
396e5c |
- if (embFile->checksum () && embFile->checksum ()->getLength () > 0)
|
|
|
396e5c |
- attachment->checksum = g_string_new_len (embFile->checksum ()->getCString (),
|
|
|
396e5c |
- embFile->checksum ()->getLength ());
|
|
|
396e5c |
- priv->obj_stream = embFile->streamObject()->copy();
|
|
|
396e5c |
+ if (embFile->checksum () && embFile->checksum ()->getLength () > 0)
|
|
|
396e5c |
+ attachment->checksum = g_string_new_len (embFile->checksum ()->getCString (),
|
|
|
396e5c |
+ embFile->checksum ()->getLength ());
|
|
|
396e5c |
+ priv->obj_stream = embFile->streamObject()->copy();
|
|
|
396e5c |
+ }
|
|
|
396e5c |
+ else
|
|
|
396e5c |
+ {
|
|
|
396e5c |
+ g_warning ("Missing stream object for embedded file");
|
|
|
396e5c |
+ g_clear_object (&attachment);
|
|
|
396e5c |
+ }
|
|
|
396e5c |
|
|
|
396e5c |
return attachment;
|
|
|
396e5c |
}
|
|
|
396e5c |
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
|
|
|
396e5c |
index b343eb90..df0aa47f 100644
|
|
|
396e5c |
--- a/glib/poppler-document.cc
|
|
|
396e5c |
+++ b/glib/poppler-document.cc
|
|
|
396e5c |
@@ -666,7 +666,8 @@ poppler_document_get_attachments (PopplerDocument *document)
|
|
|
396e5c |
attachment = _poppler_attachment_new (emb_file);
|
|
|
396e5c |
delete emb_file;
|
|
|
396e5c |
|
|
|
396e5c |
- retval = g_list_prepend (retval, attachment);
|
|
|
396e5c |
+ if (attachment != NULL)
|
|
|
396e5c |
+ retval = g_list_prepend (retval, attachment);
|
|
|
396e5c |
}
|
|
|
396e5c |
return g_list_reverse (retval);
|
|
|
396e5c |
}
|
|
|
396e5c |
--
|
|
|
396e5c |
2.17.0
|
|
|
396e5c |
|