Skip to content

Commit

Permalink
Fraction: fix more integer overflows (Clusterfuzz 63287)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 16, 2023
1 parent e7d8563 commit bcb4cb2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Fraction::Fraction(int64_t num, int64_t den)
Fraction Fraction::operator+(const Fraction& b) const
{
if (denominator == b.denominator) {
return Fraction{numerator + b.numerator, denominator};
int64_t n = numerator + b.numerator;
int64_t d = denominator;
return Fraction{n,d};
}
else {
int64_t n = int64_t{numerator} * b.denominator + int64_t{b.numerator} * denominator;
Expand All @@ -97,7 +99,9 @@ Fraction Fraction::operator+(const Fraction& b) const
Fraction Fraction::operator-(const Fraction& b) const
{
if (denominator == b.denominator) {
return Fraction{numerator - b.numerator, denominator};
int64_t n = numerator - b.numerator;
int64_t d = denominator;
return Fraction{n,d};
}
else {
int64_t n = int64_t{numerator} * b.denominator - int64_t{b.numerator} * denominator;
Expand Down

0 comments on commit bcb4cb2

Please sign in to comment.