Skip to content

Commit

Permalink
use correct longInt accessor in equality test
Browse files Browse the repository at this point in the history
We incorrectly accessed the longLongIntValue_ section of the union when
comparing a lont int and an unsigned long long int.

This resulted in incorrect behavior on some 32bit platforms. This is
likely due to the union not being zero initialized.

Fix this by using the correct accessor, longIntValue_.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
  • Loading branch information
jacob-keller committed Aug 10, 2018
1 parent 7248404 commit 66d3e7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/CppUTestExt/MockNamedValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ bool MockNamedValue::equals(const MockNamedValue& p) const
else if ((type_ == "unsigned long long int") && (p.type_ == "long int"))
return (p.value_.longIntValue_ >= 0) && (value_.unsignedLongLongIntValue_ == (unsigned long long)p.value_.longIntValue_);
else if ((type_ == "long int") && (p.type_ == "unsigned long long int"))
return (value_.longIntValue_ >= 0) && ((unsigned long long)value_.longLongIntValue_ == p.value_.unsignedLongLongIntValue_);
return (value_.longIntValue_ >= 0) && ((unsigned long long)value_.longIntValue_ == p.value_.unsignedLongLongIntValue_);
else if ((type_ == "unsigned long long int") && (p.type_ == "unsigned long int"))
return value_.unsignedLongLongIntValue_ == p.value_.unsignedLongIntValue_;
else if ((type_ == "unsigned long int") && (p.type_ == "unsigned long long int"))
Expand Down

0 comments on commit 66d3e7b

Please sign in to comment.