Bug #27759 [Com]: bcadd() causes crash if first parameter is empty string

From: Date: Mon, 29 Aug 2011 08:06:32 +0000
Subject: Bug #27759 [Com]: bcadd() causes crash if first parameter is empty string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-163018@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=27759&edit=1 ID: 27759 Comment by: good821 at 126 dot com Reported by: patrick at rap-x dot com Summary: bcadd() causes crash if first parameter is empty string Status: Closed Type: Bug Package: BC math related Operating System: win32 only PHP Version: 5.0.0RC1 Block user comment: N Private report: N New Comment: http://www.officialoaklandraiders.com/jason-campbell-jersey-c-11_33.html Jason Campbell Jersey http://www.officialoaklandraiders.com/jim-otto-jersey-c-11_41.html Jim Otto Throwback Jersey http://www.officialoaklandraiders.com/jim-plunkett-jersey-c-11_24.html Jim Plunkett Throwback Jersey Previous Comments: ------------------------------------------------------------------------ [2011-08-29 08:06:09] good821 at 126 dot com http://www.officialoaklandraiders.com/howie-long-jersey-c-11_18.html Howie Long Throwback Jersey http://www.officialoaklandraiders.com/jack-tatum-jersey-c-11_37.html Jack Tatum Throwback Jersey http://www.officialoaklandraiders.com/jacoby-ford-jersey-c-11_38.html Jacoby Ford Jersey ------------------------------------------------------------------------ [2004-07-26 19:58:57] pollita@php.net The fix was located just *after* the release of 5.0.0 (literally, like, the next day), look for it in 5.0.1. ------------------------------------------------------------------------ [2004-07-25 00:22:19] davesk78 at yahoo dot com This bug still exists in the final release (5.0.0). I'm running Apache 2, PHP 5.0.0, and Windows XP Pro. Same test case: $total = "0"; $diff = ""; $result = bcadd($total, $diff, 6); echo $result; exit; The following also causes Apache to crash: $total = "0"; $diff = ""; $result = bcpow($total, $diff, 6); echo $result; exit; ------------------------------------------------------------------------ [2004-07-07 15:48:45] pk at onpk dot net The reproduce code still crashes on my box Windows 2000 pro, Apache 1.3.27, PHP5 build 2195. And not only with "bcadd" but also with : $total = "0"; $diff = ""; bcpow($total, $diff, 6); And : $total = "0"; $diff = ""; bcsub($total, $diff, 6); However I've to admit that ttt_cao at hotmail dot com's remedy does work. By the way, I'm not using PEAR`s Benchmark_Timer. Hope someone will look at this. Thanks in advance. Perrick :: http://www.onpk.net/ ------------------------------------------------------------------------ [2004-06-29 18:51:18] ttt_cao at hotmail dot com update the function getProfiling() in timer.php as the follows, maybe you can fix the bug. function getProfiling() { $i = 0; $total = $temp = '0.0'; $result = array(); foreach ($this->markers as $marker => $time) { if (extension_loaded('bcmath')) { $diff = bcsub($time, $temp, 6); if ($i > 0) $total = bcadd($total, $diff, 6); } else { $diff = $time - $temp; $total = $total + $diff; } echo "$time $diff $total <br>"; $result[$i]['name'] = $marker; $result[$i]['time'] = $time; $result[$i]['diff'] = $diff; $result[$i]['total'] = $total; $this->strlen_max = (strlen($marker) > $this->strlen_max ? strlen($marker) + 1 : $this->strlen_max); $temp = $time; $i++; } $result[0]['diff'] = '-'; $this->strlen_max = (strlen('total') > $this->strlen_max ? strlen('total') : $this->strlen_max); $this->strlen_max += 4; return $result; } ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=27759 -- Edit this bug report at https://bugs.php.net/bug.php?id=27759&edit=1

« previous php.bugs (#163018) next »