Skip to content

Commit

Permalink
fix: undefined behavior in IntegerType::compare function (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosthi committed Sep 27, 2024
1 parent 6fa20ec commit d36c99d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/observer/common/type/integer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ int IntegerType::compare(const Value &left, const Value &right) const
if (right.attr_type() == AttrType::INTS) {
return common::compare_int((void *)&left.value_.int_value_, (void *)&right.value_.int_value_);
} else if (right.attr_type() == AttrType::FLOATS) {
return common::compare_float((void *)&left.value_.int_value_, (void *)&right.value_.int_value_);
float left_val = left.get_float();
float right_val = right.get_float();
return common::compare_float((void *)&left_val, (void *)&right_val);
}
return INT32_MAX;
}
Expand Down

0 comments on commit d36c99d

Please sign in to comment.