From 2a55a06f81abeccf55a2ed475025526fec3a5ff1 Mon Sep 17 00:00:00 2001 From: nihui Date: Thu, 25 Mar 2021 21:52:23 +0800 Subject: [PATCH] fix build --- highgui/src/exif.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/highgui/src/exif.cpp b/highgui/src/exif.cpp index 0c4ab20b..29449f96 100644 --- a/highgui/src/exif.cpp +++ b/highgui/src/exif.cpp @@ -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; } @@ -150,11 +146,11 @@ std::map ExifReader::getExif() case COM: bytesToSkip = getFieldSize(); if (bytesToSkip < markerSize) { - throw ExifParsingError(); + return std::map(); } m_stream.seekg( static_cast( bytesToSkip - markerSize ), m_stream.cur ); if ( m_stream.fail() ) { - throw ExifParsingError(); + return std::map(); } break; @@ -165,12 +161,12 @@ std::map ExifReader::getExif() case APP1: //actual Exif Marker exifSize = getFieldSize(); if (exifSize <= offsetToTiffHeader) { - throw ExifParsingError(); + return std::map(); } m_data.resize( exifSize - offsetToTiffHeader ); m_stream.seekg( static_cast( offsetToTiffHeader ), m_stream.cur ); if ( m_stream.fail() ) { - throw ExifParsingError(); + return std::map(); } m_stream.read( reinterpret_cast(&m_data[0]), exifSize - offsetToTiffHeader ); exifFound = true; @@ -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::const_iterator it = m_data.begin() + dataOffset; std::string result( it, it + size ); //copy vector content into result @@ -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 ) { @@ -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 ) {