Skip to content

Commit

Permalink
prevent invalid values in LineOrder enum
Browse files Browse the repository at this point in the history
Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Aug 9, 2020
1 parent 6bb6257 commit 93e9f2a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions OpenEXR/IlmImf/ImfLineOrderAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ LineOrderAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is,
{
unsigned char tmp;
Xdr::read <StreamIO> (is, tmp);

//
// prevent invalid values being written to LineOrder enum
// by forcing all unknown types to NUM_LINEORDERS which is also an invalid
// value but is a legal enum. Note that Header::sanityCheck will
// throw an exception when files with invalid lineOrders
//

if (tmp != INCREASING_Y &&
tmp != DECREASING_Y &&
tmp != RANDOM_Y)
tmp = NUM_LINEORDERS;

_value = LineOrder (tmp);
}

Expand Down

0 comments on commit 93e9f2a

Please sign in to comment.