Fix switch value in BigTiffImage::readData

This function extracts a 2, 4 or 8 byte integer from the image and
swaps it according to the current setting. However, it was implicitly
assuming, that it reads the same amount from the image is is
requested.
If that is not the case, e.g. if 8 bytes are requested but
only 4 are read
=> result is created via byteSwap8() which reads 8 bytes
   !but 4 of those are uninitialized!
Using the actually read size fixes this problem.
v0.27.3
Dan Čermák 7 years ago
parent ecf955812d
commit 67ec90bdab

@ -416,13 +416,13 @@ namespace Exiv2
uint64_t result = 0;
if (size == 1)
{}
else if (size == 2)
if (data.size_ == 1)
{}
else if (data.size_ == 2)
result = byteSwap2(data, 0, doSwap_);
else if (size == 4)
else if (data.size_ == 4)
result = byteSwap4(data, 0, doSwap_);
else if (size == 8)
else if (data.size_ == 8)
result = byteSwap8(data, 0, doSwap_);
else
throw Exiv2::Error(kerCorruptedMetadata);

Loading…
Cancel
Save