Bug 129971 - kpdf crashes after clicking on "print preview".
Summary: kpdf crashes after clicking on "print preview".
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: OpenSUSE Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-28 15:33 UTC by GMkl
Modified: 2006-06-28 21:18 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
This file leads to crash on "print preview" (69.07 KB, application/octet-stream)
2006-06-28 15:35 UTC, GMkl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description GMkl 2006-06-28 15:33:41 UTC
Version:           0.5.3 (using KDE KDE 3.5.3)
Installed from:    SuSE RPMs
OS:                Linux

kpdf correctly displays a certain file. After clicking on "print preview", kpdf crashes. Other pdf files can be previewed without problems. When started from the command line, it outputs "Improper call to JPEG library in state 205" immediately before crashing.
Comment 1 GMkl 2006-06-28 15:35:19 UTC
Created attachment 16818 [details]
This file leads to crash on "print preview"
Comment 2 GMkl 2006-06-28 15:36:26 UTC
Maybe there is a correspondance to bug #118303.
Comment 3 Albert Astals Cid 2006-06-28 21:18:47 UTC
SVN commit 555943 by aacid:

Reset the jpeg structures on reset.
BUGS: 129971

Fix will be on KDE 3.5.4



 M  +18 -7     DCTStream.cc  
 M  +2 -0      DCTStream.h  


--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/DCTStream.cc #555942:555943
@@ -54,7 +54,16 @@
 
 DCTStream::DCTStream(Stream *strA):
   FilterStream(strA) {
-  
+  init();
+}
+
+DCTStream::~DCTStream() {
+  jpeg_destroy_decompress(&cinfo);
+  delete str;
+}
+
+void DCTStream::init()
+{
   jpeg_create_decompress(&cinfo);
   src.pub.init_source = str_init_source;
   src.pub.fill_input_buffer = str_fill_input_buffer;
@@ -68,18 +77,20 @@
   cinfo.src = (jpeg_source_mgr *)&src;
   cinfo.err = jpeg_std_error(&jerr);
   x = 0;
+  row_buffer = NULL;
 }
 
-DCTStream::~DCTStream() {
-  jpeg_destroy_decompress(&cinfo);
-  delete str;
-}
-
 void DCTStream::reset() {
   int row_stride;
 
   str->reset();
-  
+
+  if (row_buffer)
+  {
+    jpeg_destroy_decompress(&cinfo);
+    init();
+  }
+
   // JPEG data has to start with 0xFF 0xD8
   // but some pdf like the one on 
   // https://bugs.freedesktop.org/show_bug.cgi?id=3299
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/DCTStream.h #555942:555943
@@ -62,6 +62,8 @@
   Stream *getRawStream() { return str; }
 
 private:
+  void init();
+
   unsigned int x;
   struct jpeg_decompress_struct cinfo;
   struct jpeg_error_mgr jerr;