glib/poppler-document.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
New commits: commit d1f1a354d512645c616941b56aaf30641e89959f Author: Simon McVittie <[email protected]> Date: Tue May 28 12:37:24 2019 +0100 glib: Document G_IO_ERROR as a possible error condition This was already implicit from G_IO_ERROR_NOT_SUPPORTED being a documented error condition, and from the use of GCancellable, but is probably clearer when spelled out explicitly. The addition of g_seekable_seek() and g_seekable_tell() in the previous commit might add more error conditions in the same domain. Signed-off-by: Simon McVittie <[email protected]> diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index fdaa8b0f..49c9ed3a 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -276,8 +276,8 @@ stream_is_memory_buffer_or_local_file (GInputStream *stream) * Creates a new #PopplerDocument reading the PDF contents from @stream. * Note that the given #GInputStream must be seekable or %G_IO_ERROR_NOT_SUPPORTED * will be returned. - * Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR - * domains. + * Possible errors include those in the #POPPLER_ERROR, #G_FILE_ERROR + * and #G_IO_ERROR domains. * * Returns: (transfer full): a new #PopplerDocument, or %NULL * commit aa432bc0be1a8b9f74b85ae78590f11dc6949c8b Author: Simon McVittie <[email protected]> Date: Thu Feb 14 09:43:32 2019 +0000 glib: Don't create PopplerInputStream with length 0 Since commit a59f6164, PopplerInputStream requires a nonzero length. Loosely based on an earlier patch by Kouhei Sutou. This version adds support for length == -1, which is documented to work. Resolves: https://gitlab.freedesktop.org/poppler/poppler/issues/414 Bug-Debian: https://bugs.debian.org/896596 diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index cd7e8ebf..fdaa8b0f 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -308,7 +308,14 @@ poppler_document_new_from_stream (GInputStream *stream, } if (stream_is_memory_buffer_or_local_file(stream)) { - str = new PopplerInputStream(stream, cancellable, 0, false, 0, Object(objNull)); + if (length == (goffset)-1) { + if (!g_seekable_seek(G_SEEKABLE(stream), 0, G_SEEK_END, cancellable, error)) { + g_prefix_error(error, "Unable to determine length of stream: "); + return nullptr; + } + length = g_seekable_tell(G_SEEKABLE(stream)); + } + str = new PopplerInputStream(stream, cancellable, 0, false, length, Object(objNull)); } else { CachedFile *cachedFile = new CachedFile(new PopplerCachedFileLoader(stream, cancellable, length), new GooString()); str = new CachedFileStream(cachedFile, 0, false, cachedFile->getLength(), Object(objNull)); _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
