File poppler-CVE-2018-19149.patch of Package poppler.34111

Index: poppler-0.43.0/glib/poppler-document.cc
===================================================================
--- poppler-0.43.0.orig/glib/poppler-document.cc
+++ poppler-0.43.0/glib/poppler-document.cc
@@ -667,7 +667,8 @@ poppler_document_get_attachments (Popple
       attachment = _poppler_attachment_new (emb_file);
       delete emb_file;
 
-      retval = g_list_prepend (retval, attachment);
+      if (attachment != NULL)
+        retval = g_list_prepend (retval, attachment);
     }
   return g_list_reverse (retval);
 }
Index: poppler-0.43.0/glib/poppler-attachment.cc
===================================================================
--- poppler-0.43.0.orig/glib/poppler-attachment.cc
+++ poppler-0.43.0/glib/poppler-attachment.cc
@@ -117,20 +117,28 @@ _poppler_attachment_new (FileSpec *emb_f
     attachment->description = _poppler_goo_string_to_utf8 (emb_file->getDescription ());
 
   embFile = emb_file->getEmbeddedFile();
-  attachment->size = embFile->size ();
-
-  if (embFile->createDate ())
-    _poppler_convert_pdf_date_to_gtime (embFile->createDate (), (time_t *)&attachment->ctime);
-  if (embFile->modDate ())
-    _poppler_convert_pdf_date_to_gtime (embFile->modDate (), (time_t *)&attachment->mtime);
-
-  if (embFile->checksum () && embFile->checksum ()->getLength () > 0)
-    attachment->checksum = g_string_new_len (embFile->checksum ()->getCString (),
-                                             embFile->checksum ()->getLength ());
-  priv->obj_stream = new Object();
-  priv->obj_stream->initStream(embFile->stream());
-  // Copy the stream
-  embFile->stream()->incRef();
+  if (embFile != NULL && embFile->isOk())
+    {
+      attachment->size = embFile->size ();
+    
+      if (embFile->createDate ())
+        _poppler_convert_pdf_date_to_gtime (embFile->createDate (), (time_t *)&attachment->ctime);
+      if (embFile->modDate ())
+        _poppler_convert_pdf_date_to_gtime (embFile->modDate (), (time_t *)&attachment->mtime);
+    
+      if (embFile->checksum () && embFile->checksum ()->getLength () > 0)
+        attachment->checksum = g_string_new_len (embFile->checksum ()->getCString (),
+                                                 embFile->checksum ()->getLength ());
+      priv->obj_stream = new Object();
+      priv->obj_stream->initStream(embFile->stream());
+      // Copy the stream
+      embFile->stream()->incRef();
+    }
+  else
+    {
+      g_warning ("Missing stream object for embedded file");
+      g_clear_object (&attachment);
+    }
 
   return attachment;
 }
openSUSE Build Service is sponsored by