From 4a294775da7ead4023aef5752b64fa0b0c20d643 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Tue, 8 Dec 2015 16:38:59 +0300 Subject: [PATCH] Coverity: fixed uninitialized field in ExifReader --- modules/imgcodecs/src/grfmt_jpeg.cpp | 6 +++++- modules/imgcodecs/src/jpeg_exif.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp index 6862a06ebb..8a2900a194 100644 --- a/modules/imgcodecs/src/grfmt_jpeg.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg.cpp @@ -270,7 +270,11 @@ int JpegDecoder::getOrientation() ExifReader reader( m_filename ); if( reader.parse() ) { - orientation = reader.getTag( ORIENTATION ).field_u16;//orientation is unsigned short, so check field_u16 + ExifEntry_t entry = reader.getTag( ORIENTATION ); + if (entry.tag != INVALID_TAG) + { + orientation = entry.field_u16; //orientation is unsigned short, so check field_u16 + } } return orientation; diff --git a/modules/imgcodecs/src/jpeg_exif.cpp b/modules/imgcodecs/src/jpeg_exif.cpp index d10ad55540..103e72ddec 100644 --- a/modules/imgcodecs/src/jpeg_exif.cpp +++ b/modules/imgcodecs/src/jpeg_exif.cpp @@ -54,14 +54,14 @@ namespace cv ExifEntry_t::ExifEntry_t() : field_float(0), field_double(0), field_u32(0), field_s32(0), - tag(0), field_u16(0), field_s16(0), field_u8(0), field_s8(0) + tag(INVALID_TAG), field_u16(0), field_s16(0), field_u8(0), field_s8(0) { } /** * @brief ExifReader constructor */ -ExifReader::ExifReader(std::string filename) : m_filename(filename) +ExifReader::ExifReader(std::string filename) : m_filename(filename), m_format(NONE) { }