Fix bug in Cr2Header::read

This commit is contained in:
Luis Diaz Mas 2018-05-24 23:51:05 +02:00 committed by Luis Díaz Más
parent b1c34ee11f
commit 59493d1edc
2 changed files with 5 additions and 3 deletions

View File

@ -17,7 +17,9 @@ namespace Exiv2 {
bool Cr2Header::read(const byte* pData, uint32_t size)
{
if (size < 16) return false;
if (!pData || size < 16) {
return false;
}
if (pData[0] == 'I' && pData[0] == pData[1]) {
setByteOrder(littleEndian);

View File

@ -39,8 +39,8 @@ TEST(ACr2Header, failToReadDataFromBufferWithCorrectSizeButNull)
TEST(ACr2Header, failToReadDataFromBufferWithSizeDifferentThan16)
{
Internal::Cr2Header header;
ASSERT_FALSE(header.read(NULL, 15));
ASSERT_FALSE(header.read(NULL, 17));
ASSERT_FALSE(header.read(cr2LittleEndian, 15));
ASSERT_FALSE(header.read(cr2LittleEndian, 0));
}
TEST(ACr2Header, failToReadDataFromBufferWithInvalidByteOrder)