From Oliver Neumann,

"I checked your solution and found one missing point which makes it still produce the tif error:
The very first seek_set on the empty stream with zero offset."

"This means that the empty stream is seeked again resulting in the fail bit to be set. Your code does not check this case, furthermore you use t_off instead of std::ostream::streampos for the tellp() calls. In this special case (empty stream) tellp() returns -1 which is cast to 0xFFFFFFFFFF as t_off is unsigned. I suggest this addition to your code (within the switch statement)"
This commit is contained in:
Robert Osfield 2011-05-26 16:16:11 +00:00
parent b507858240
commit 0a1ecd3272

View File

@ -183,6 +183,14 @@ toff_t libtiffOStreamSeekProc(thandle_t fd, toff_t off, int i)
{ {
case SEEK_SET: case SEEK_SET:
{ {
if (off==0)
{
std::ostream::streampos checkEmpty = fout->tellp();
if(checkEmpty < 0)
{
return 0;
}
}
pos_required = off; pos_required = off;
fout->seekp(0, std::ios::end); fout->seekp(0, std::ios::end);