Bug 179447 - [Patch] Empty comicbook crash
Summary: [Patch] Empty comicbook crash
Status: CLOSED FIXED
Alias: None
Product: okular
Classification: Applications
Component: Comicbook backend (show other bugs)
Version: unspecified
Platform: Compiled Sources Unspecified
: NOR crash
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: testcase
Depends on:
Blocks:
 
Reported: 2009-01-03 03:46 UTC by David Palacio
Modified: 2009-12-09 19:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
testcase (144 bytes, application/x-cbz)
2009-01-03 03:48 UTC, David Palacio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Palacio 2009-01-03 03:46:42 UTC
Version:            (using Devel)
Installed from:    Compiled sources

When a cbz/cbr file contains zero image files the generator in the Okular core is undefined causing this crash:

#0  0x00007f4efe9e5b0a in Okular::Document::openDocument (this=0x1c1ba00, docFile=@0x7fff12f1b7b0, url=<value optimized out>, _mime=<value optimized out>)
    at ../../okular/core/document.cpp:1663
#1  0x00007f4efbb018b0 in Part::openFile (this=0x1b80420) at ../../okular/part.cpp:874
#2  0x00007f4f0298af34 in KParts::ReadOnlyPart::openUrl (this=0x1b80420, url=<value optimized out>) at ../../kparts/part.cpp:558


Patch for the Comicbook generator. Or maybe the fix should go instead inside Okular for 0 pages opened documents.
Index: document.cpp
===================================================================
--- document.cpp        (revisión: 900827)
+++ document.cpp        (copia de trabajo)
@@ -105,7 +105,7 @@
         return false;
     }

-    return true;
+    return mPageMap.size() > 0;
 }

 void Document::close()


Testcase is the attachment in the next message
Comment 1 David Palacio 2009-01-03 03:48:12 UTC
Created attachment 29853 [details]
testcase

Open in Okular crash.cbz
Comment 2 Brad Hards 2009-01-03 10:58:12 UTC
Can reproduce.

Seems we should protect against this in core:

--- okular/core/document.cpp    (revision 903994)
+++ okular/core/document.cpp    (working copy)
@@ -1660,6 +1660,9 @@
     AudioPlayer::instance()->d->m_currentDocument = isstdin ? KUrl() : d->m_url;
     d->m_docSize = document_size;

+    if ( !d->m_generator )
+        return false;
+
     const QStringList docScripts = d->m_generator->metaData( "DocumentScripts", "JavaScript" ).toStringList();
     if ( !docScripts.isEmpty() )
     {
Comment 3 Pino Toscano 2009-01-03 11:16:02 UTC
D'oh, I put a protection against empty documents in the core, but forgot to actual set that the loading fails in that case.
Fix coming in a minute.
Comment 4 Pino Toscano 2009-01-03 11:17:16 UTC
SVN commit 904821 by pino:

When the loaded document is empty, consider its loading as failed.
(Added a TODO for a proper UI message.)
BUG: 179447


 M  +4 -0      document.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=904821
Comment 5 Pino Toscano 2009-01-03 11:19:50 UTC
KDE 4.1.x is not affected, as this slipped in with a small refactoring of the loading routines (shame on me).
Thanks for the bug report and the test case!