Skip to content

Commit

Permalink
fix: Correct the function png_fp_sub in png.c
Browse files Browse the repository at this point in the history
The code erroneously evaluated `addend0+addend1` in the case where
`addend1` is less than zero.  The function is meant to subtract the
second argument from the first.

Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
  • Loading branch information
jbowler authored and ctruta committed Oct 10, 2024
1 parent ed68998 commit 79fd6d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion png.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error)
else if (addend1 < 0)
{
if (0x7fffffff + addend1 >= addend0)
return addend0+addend1;
return addend0-addend1;
}
else
return addend0;
Expand Down

0 comments on commit 79fd6d1

Please sign in to comment.