Bug #64736 [NEW]: Incorrect calculation in gdColorMatch

From: Date: Mon, 29 Apr 2013 23:05:06 +0000
Subject: Bug #64736 [NEW]: Incorrect calculation in gdColorMatch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178700@lists.php.net to get a copy of this message
From:             sixd
Operating system: Linux
PHP version:      5.5Git-2013-04-29 (Git)
Package:          GD related
Bug Type:         Bug
Bug description:Incorrect calculation in gdColorMatch

Description:
------------
Compilations warnings in gd_crop.c flag a potential calculation issue in
gdColorMatch:

/home/cjones/php-5.5/ext/gd/libgd/gd_crop.c:340: warning: suggest
parentheses around arithmetic in operand of ^
/home/cjones/php-5.5/ext/gd/libgd/gd_crop.c:340: warning: suggest
parentheses around arithmetic in operand of ^

The code at line 340 is:

	const double dist_perc = sqrt(dist / (255^2 + 255^2 + 255^2));

The denominator is currently evaluated as 253. Was it instead intended be
(3 * (255 * 255)) == 195075 ?


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64736&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=64736&r=trysnapshot54
Try a snapshot (PHP 5.3):   https://bugs.php.net/fix.php?id=64736&r=trysnapshot53
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=64736&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64736&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64736&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64736&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64736&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64736&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64736&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64736&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=64736&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=64736&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64736&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64736&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64736&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64736&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64736&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64736&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64736&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64736&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#178700) next »