Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Mar 25, 2021
1 parent 4de5309 commit 2a55a06
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions highgui/src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ ExifReader::~ExifReader()
*/
bool ExifReader::parse()
{
try {
m_exif = getExif();
if( !m_exif.empty() )
{
return true;
}
return false;
} catch (ExifParsingError&) {
return false;
m_exif = getExif();
if( !m_exif.empty() )
{
return true;
}
return false;
}


Expand Down Expand Up @@ -150,11 +146,11 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case COM:
bytesToSkip = getFieldSize();
if (bytesToSkip < markerSize) {
throw ExifParsingError();
return std::map<int, ExifEntry_t >();
}
m_stream.seekg( static_cast<long>( bytesToSkip - markerSize ), m_stream.cur );
if ( m_stream.fail() ) {
throw ExifParsingError();
return std::map<int, ExifEntry_t >();
}
break;

Expand All @@ -165,12 +161,12 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case APP1: //actual Exif Marker
exifSize = getFieldSize();
if (exifSize <= offsetToTiffHeader) {
throw ExifParsingError();
return std::map<int, ExifEntry_t >();
}
m_data.resize( exifSize - offsetToTiffHeader );
m_stream.seekg( static_cast<long>( offsetToTiffHeader ), m_stream.cur );
if ( m_stream.fail() ) {
throw ExifParsingError();
return std::map<int, ExifEntry_t >();
}
m_stream.read( reinterpret_cast<char*>(&m_data[0]), exifSize - offsetToTiffHeader );
exifFound = true;
Expand Down Expand Up @@ -414,7 +410,7 @@ std::string ExifReader::getString(const size_t offset) const
dataOffset = getU32( offset + 8 );
}
if (dataOffset > m_data.size() || dataOffset + size > m_data.size()) {
throw ExifParsingError();
return std::string();
}
std::vector<uint8_t>::const_iterator it = m_data.begin() + dataOffset;
std::string result( it, it + size ); //copy vector content into result
Expand All @@ -431,7 +427,7 @@ std::string ExifReader::getString(const size_t offset) const
uint16_t ExifReader::getU16(const size_t offset) const
{
if (offset + 1 >= m_data.size())
throw ExifParsingError();
return 0;

if( m_format == INTEL )
{
Expand All @@ -449,7 +445,7 @@ uint16_t ExifReader::getU16(const size_t offset) const
uint32_t ExifReader::getU32(const size_t offset) const
{
if (offset + 3 >= m_data.size())
throw ExifParsingError();
return 0;

if( m_format == INTEL )
{
Expand Down

0 comments on commit 2a55a06

Please sign in to comment.