From 0a1ecd3272fc19aac616c753cdb6cf85e9c1cc92 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 26 May 2011 16:16:11 +0000 Subject: [PATCH] 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)" --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 5f66169f0..e463b7825 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -183,6 +183,14 @@ toff_t libtiffOStreamSeekProc(thandle_t fd, toff_t off, int i) { case SEEK_SET: { + if (off==0) + { + std::ostream::streampos checkEmpty = fout->tellp(); + if(checkEmpty < 0) + { + return 0; + } + } pos_required = off; fout->seekp(0, std::ios::end);