Bug #469
MemIo behaviour differs from FILE* and FileIo
0%
Description
When using readMetadata() on a TIFF that has been opened using
Exiv2::ImageFactory::open(ptr,size) I always get an exception because
EOF is reached. I think this is expected however because the relevant
code just read in a number of bytes equal to the amount of the
stream's size (tiffimage.cpp:133).
The exception only occurs when using MemIo, FileIo doesn't return true
for eof() after reading in size() bytes.
(Reported by Dimitri)
Thanks, this looks like a bug in MemIo. A quick read test with a
buffer and file of the same size gives this:
$ ./try
Testing 10 bytes
MemIo : ..........
FileIo: ...........
FILE : ...........
// ----------------------------------------------
#include "basicio.hpp"
#include <iostream>
#include <cstdio>
using namespace Exiv2;
int main()
{
DataBuf buf(10);
FILE* f = fopen("ttt", "wb");
std::cout << "Testing "
<< fwrite(buf.pData_, 1, buf.size_, f)
<< " bytes\n";
fclose(f);
MemIo mIo(buf.pData_, buf.size_);
std::cout << "MemIo : ";
while(!mIo.eof()) {
mIo.getb();
std::cout << ".";
}
std::cout << "\n";
FileIo fIo("ttt");
fIo.open();
std::cout << "FileIo: ";
while(!fIo.eof()) {
fIo.getb();
std::cout << ".";
}
std::cout << "\n";
f = fopen("ttt", "rb");
std::cout << "FILE : ";
while(!feof(f)) {
fread(buf.pData_, 1, 1, f);
std::cout << ".";
}
std::cout << "\n";
return 0;
}