Skip to content

Commit

Permalink
fix comparison of unsigned expression < 0 (Issue #165)
Browse files Browse the repository at this point in the history
  • Loading branch information
CAHEK7 authored and nickrasmussen committed Aug 8, 2018
1 parent b0b5079 commit 9e3913c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions IlmBase/Imath/ImathInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ IMATH_INTERNAL_NAMESPACE_HEADER_ENTER

#if (defined _WIN32 || defined _WIN64) && _MSC_VER >= 1300
typedef unsigned __int64 Int64;
typedef __int64 SInt64;
#elif ULONG_MAX == 18446744073709551615LU
typedef long unsigned int Int64;
typedef long int SInt64;
#else
typedef long long unsigned int Int64;
typedef long long int SInt64;
#endif


Expand Down
20 changes: 10 additions & 10 deletions OpenEXR/IlmImf/ImfDwaCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2397,15 +2397,15 @@ DwaCompressor::uncompress
"(truncated file).");
}

if (unknownUncompressedSize < 0 ||
unknownCompressedSize < 0 ||
acCompressedSize < 0 ||
dcCompressedSize < 0 ||
rleCompressedSize < 0 ||
rleUncompressedSize < 0 ||
rleRawSize < 0 ||
totalAcUncompressedCount < 0 ||
totalDcUncompressedCount < 0)
if ((SInt64)unknownUncompressedSize < 0 ||
(SInt64)unknownCompressedSize < 0 ||
(SInt64)acCompressedSize < 0 ||
(SInt64)dcCompressedSize < 0 ||
(SInt64)rleCompressedSize < 0 ||
(SInt64)rleUncompressedSize < 0 ||
(SInt64)rleRawSize < 0 ||
(SInt64)totalAcUncompressedCount < 0 ||
(SInt64)totalDcUncompressedCount < 0)
{
throw Iex::InputExc("Error uncompressing DWA data"
" (corrupt header).");
Expand Down Expand Up @@ -2496,7 +2496,7 @@ DwaCompressor::uncompress
// start of the data block.
//

if ((version < 0) || (version > 2))
if (version > 2)
throw Iex::InputExc ("Invalid version of compressed data block");

setupChannelData(minX, minY, maxX, maxY);
Expand Down
1 change: 1 addition & 0 deletions OpenEXR/IlmImf/ImfInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER

using IMATH_NAMESPACE::Int64;
using IMATH_NAMESPACE::SInt64;

OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT

Expand Down

0 comments on commit 9e3913c

Please sign in to comment.