Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #47 from pedrocr/coverity-fixes
Browse files Browse the repository at this point in the history
Fix a few small issues found by coverity
  • Loading branch information
klauspost committed Aug 25, 2014
2 parents 5cfaa91 + 4180361 commit 19f5832
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion RawSpeed/ArwDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void ArwDecoder::DecodeARW(ByteStream &input, uint32 w, uint32 h) {
if (len == 4)
while (len < 17 && !bits.getBitNoFill()) len++;
int diff = bits.getBits(len);
if ((diff & (1 << (len - 1))) == 0)
if (len && (diff & (1 << (len - 1))) == 0)
diff -= (1 << len) - 1;
sum += diff;
_ASSERTE(!(sum >> 12));
Expand Down
2 changes: 1 addition & 1 deletion RawSpeed/DcrDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void DcrDecoder::decodeKodak65000Segment(ByteStream &input, ushort16 *out, uint3
uint32 diff = (uint32)bitbuf & (0xffff >> (16-len));
bitbuf >>= len;
bits -= len;
if ((diff & (1 << (len-1))) == 0)
if (len && (diff & (1 << (len-1))) == 0)
diff -= (1 << len) - 1;
out[i] = diff;
}
Expand Down
4 changes: 2 additions & 2 deletions RawSpeed/RafDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace RawSpeed {

RafDecoder::RafDecoder(TiffIFD *rootIFD, FileMap* file) :
RawDecoder(file), mRootIFD(rootIFD) {
decoderVersion = 1;
decoderVersion = 1;
alt_layout = FALSE;
}
RafDecoder::~RafDecoder(void) {
if (mRootIFD)
Expand All @@ -45,7 +46,6 @@ RawImage RafDecoder::decodeRawInternal() {
mFile = raw->getFileMap();
uint32 height = 0;
uint32 width = 0;
alt_layout = FALSE;

if (raw->hasEntry(FUJI_RAWIMAGEFULLHEIGHT)) {
height = raw->getEntry(FUJI_RAWIMAGEFULLHEIGHT)->getInt();
Expand Down
3 changes: 2 additions & 1 deletion RawSpeed/TiffEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ TiffEntry::TiffEntry(TiffTag _tag, TiffDataType _type, uint32 _count, const ucha
tag = _tag;
type = _type;
count = _count;
data_offset = -1; // Set nonsense value in case someone tries to use it
if (NULL == _data) {
uint32 bytesize = _count << datashifts[_type];
own_data = new uchar8[bytesize];
Expand Down Expand Up @@ -230,7 +231,7 @@ std::string TiffEntry::getValueAsString()
}
}
string ret(temp_string);
delete temp_string;
delete [] temp_string;
return ret;
}

Expand Down
12 changes: 5 additions & 7 deletions RawSpeed/TiffIFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ TiffIFD* TiffIFD::parseMakerNote(FileMap *f, uint32 offset, Endianness parent_en
ThrowTPE("Cannot determine Pentax makernote endianness");
data +=10;
offset = 10;
// Check for fuji signature in else block so we don't accidentally leak FileMap
} else if (0 == memcmp(fuji_signature,&data[0], sizeof(fuji_signature))) {
mFile = new FileMap(f->getDataWrt(offset), f->getSize()-offset);
offset = 12;
}

// Panasonic has the word Exif at byte 6, a complete Tiff header starts at byte 12
// This TIFF is 0 offset based
if (data[6] == 0x45 && data[7] == 0x78 && data[8] == 0x69 && data[9] == 0x66)
Expand All @@ -214,13 +219,6 @@ TiffIFD* TiffIFD::parseMakerNote(FileMap *f, uint32 offset, Endianness parent_en
offset +=20;
}

// Check for fuji signature

if (0 == memcmp(fuji_signature,&data[0], sizeof(fuji_signature))) {
mFile = new FileMap(f->getDataWrt(offset), f->getSize()-offset);
offset = 12;
}

// Some have MM or II to indicate endianness - read that
if (data[0] == 0x49 && data[1] == 0x49) {
offset +=2;
Expand Down

0 comments on commit 19f5832

Please sign in to comment.