From db97aea8d9b30c5968d4af226b84a504a28a7342 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Wed, 18 Jul 2001 16:46:51 +0000 Subject: [PATCH] fix double->long conversion --- Zend/zend_operators.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 32584ed23f9..5574748125c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -182,6 +182,7 @@ ZEND_API void convert_scalar_to_number(zval *op) } +#define DVAL_TO_LVAL(d, l) (l) = (d) > LONG_MAX ? (unsigned long) (d) : (long) (d) #define zendi_convert_to_long(op, holder, result) \ if (op==result) { \ @@ -192,7 +193,7 @@ ZEND_API void convert_scalar_to_number(zval *op) (holder).value.lval = 0; \ break; \ case IS_DOUBLE: \ - (holder).value.lval = (long) (op)->value.dval; \ + DVAL_TO_LVAL((op)->value.dval, (holder).value.lval); \ break; \ case IS_STRING: \ (holder).value.lval = strtol((op)->value.str.val, NULL, 10); \ @@ -277,7 +278,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) case IS_LONG: break; case IS_DOUBLE: - op->value.lval = (long) op->value.dval; + DVAL_TO_LVAL(op->value.dval, op->value.lval); break; case IS_STRING: strval = op->value.str.val;