cvs: php4 /ext/standard array.c
| From: | Sara Golemon | Date: | Fri, 02 May 2003 00:58:02 +0000 |
| Subject: | cvs: php4 /ext/standard array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20641@lists.php.net to get a copy of this message | ||
pollita Thu May 1 20:58:02 2003 EDT
Modified files:
/php4/ext/standard array.c
Log:
Bug Fix (22433). When the bottom of a range() is chr(0) or the top is chr(255), the for loop
carries over and never exits.
Index: php4/ext/standard/array.c
diff -u php4/ext/standard/array.c:1.226 php4/ext/standard/array.c:1.227
--- php4/ext/standard/array.c:1.226 Wed Apr 16 17:40:48 2003
+++ php4/ext/standard/array.c Thu May 1 20:58:02 2003
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.226 2003/04/16 21:40:48 moriyoshi Exp $ */
+/* $Id: array.c,v 1.227 2003/05/02 00:58:02 pollita Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -1513,25 +1513,32 @@
low = (unsigned char *)Z_STRVAL_P(zlow);
high = (unsigned char *)Z_STRVAL_P(zhigh);
- if (*low > *high) { /* Negative steps */
- if (*low - *high < lstep || lstep <= 0) {
+ if (*low > *high) { /* Negative Steps */
+ if (lstep <= 0) {
err = 1;
goto err;
}
- for (; *low >= *high; (*low) -= (unsigned int)step) {
+ for (; *low >= *high; (*low) -= (unsigned int)lstep) {
add_next_index_stringl(return_value, low, 1, 1);
+ if (((signed int)*low - lstep) < 0) {
+ break;
+ }
}
- } else if (*high > *low) { /* Positive steps */
- if (*high - *low < lstep || lstep <= 0) {
+ } else if (*high > *low) { /* Positive Steps */
+ if (lstep <= 0) {
err = 1;
goto err;
}
for (; *low <= *high; (*low) += (unsigned int)lstep) {
add_next_index_stringl(return_value, low, 1, 1);
+ if (((signed int)*low + lstep) > 255) {
+ break;
+ }
}
} else {
add_next_index_stringl(return_value, low, 1, 1);
}
+
} else if (Z_TYPE_P(zlow) == IS_DOUBLE || Z_TYPE_P(zhigh) == IS_DOUBLE || is_step_double) {
double low, high;
double_str: