Date: 04/15/00
- Next message: sagawa <email protected>: "[PHP-DEV] PHP 4.0 Bug #4150: unpack ("H4","AB") is not enough input?"
- Previous message: shkim <email protected>: "[PHP-DEV] Bug #4149: header function doesn't work when set charset in php3.ini"
- In reply to: Jon Forsberg: "[PHP-DEV] Segfault patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jon,
Isn't DBL_MAX_10_EXP much too large? There might be some better idea to
calculate the maximum length of the resulting string.
Andi
At 06:12 PM 4/14/00 +0200, Jon Forsberg wrote:
>PHP 4.0RC1 (and 3.0.15) segfaults when formatting very big numbers with
>number_format:
>
>$a="1E+32";
>print(number_format($a, 2, ",", "."));
>
>Here 1E+32 and anything over makes PHP segfault.
>The fix:
>
>--- ext/standard/math.c.orig Sun Mar 12 18:18:21 2000
>+++ ext/standard/math.c Fri Apr 14 17:26:25 2000
>@@ -25,6 +25,7 @@
> #include "phpmath.h"
>
> #include <math.h>
>+#include <float.h>
>
> #ifndef M_PI
> #define M_PI 3.14159265358979323846
>@@ -611,7 +612,7 @@
> d = -d;
> }
> dec = MAX(0,dec);
>- tmpbuf = (char *) emalloc(32+dec);
>+ tmpbuf = (char *) emalloc(1 + DBL_MAX_10_EXP + 1 + dec + 1);
>
> tmplen=sprintf(tmpbuf,"%.*f",dec,d);
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>For additional commands, e-mail: php-dev-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>
--- Andi Gutmans <andi <email protected>> http://www.zend.com/-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: sagawa <email protected>: "[PHP-DEV] PHP 4.0 Bug #4150: unpack ("H4","AB") is not enough input?"
- Previous message: shkim <email protected>: "[PHP-DEV] Bug #4149: header function doesn't work when set charset in php3.ini"
- In reply to: Jon Forsberg: "[PHP-DEV] Segfault patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

