ResetStreamPos causes SegFault if called after Read.
libPGF is an implementation of the Progressive Graphics File (PGF)
Brought to you by:
c_stamm
CPGFImage.ResetStreamPos() causes a Segmentation Fault error if called after CPGFImage.Read(...)
If I try to Read more than one ROI from an open PGFImage, the second Read fails, because the first Read left the stream in the wrong position. It looks like the ResetSreamPos function was intended to fix this, but currently it crashes too. It seems, after the first Read, CDecoder.m_stream is pointing at an invalid memory location. My current workaround is to close and re-open the PGF file after each Read call.
Hello Rene
Thank you for message. There is a simple solution for your problem: just
delete in PGFimage.cpp the last line in the second Read procedure (probably
line 561). In this line the decoder is automatically closed after reading.
While this automatic closing might be useful in non ROI reads, in ROI read
it is disruptive. After deleting this line you can read several ROIs after
each other:
pgf.Open(...)
pgf.Read(rect1);
pgf.ResetStreamPos();
pgf.Read(rect2);
pgf.Close();
void CPGFImage::Read(PGFRect& rect, int level /= 0/, CallbackPtr cb /=
nullptr/, void data /=nullptr*/
) {
...
// automatically closing: should be deleted
//if (m_currentLevel == 0) Close();
}
Chris
Quoting Rene Lindsay rjklindsay@users.sf.net:
Links:
[1] http://sourceforge.net/p/libpgf/bugs/10