[libpng17] Quieted some Coverity warnings

This commit is contained in:
Glenn Randers-Pehrson
2015-01-27 15:54:37 -06:00
parent 565e1bc1ae
commit 3043819fb2
3 changed files with 48 additions and 29 deletions

29
png.c
View File

@@ -3348,23 +3348,26 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
{
/* The required result is 1/a * 1/b; the following preserves accuracy. */
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = 1E15/a;
r /= b;
r = floor(r+.5);
if (a != 0 && b != 0)
{
double r = 1E15/a;
r /= b;
r = floor(r+.5);
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
#else
/* This may overflow because the range of png_fixed_point isn't symmetric,
* but this API is only used for the product of file and screen gamma so it
* doesn't matter that the smallest number it can produce is 1/21474, not
* 1/100000
*/
png_fixed_point res = png_product2(a, b);
/* This may overflow because the range of png_fixed_point isn't
* symmetric, but this API is only used for the product of file and
* screen gamma so it doesn't matter that the smallest number it can
* produce is 1/21474, not 1/100000
*/
png_fixed_point res = png_product2(a, b);
if (res != 0)
return png_reciprocal(res);
if (res != 0)
return png_reciprocal(res);
#endif
}
return 0; /* overflow */
}