summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 5905ae4929..183cf123c3 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2099,10 +2099,18 @@ PHP_FUNCTION(range)
}
if (zstep) {
- if (Z_TYPE_P(zstep) == IS_DOUBLE ||
- (Z_TYPE_P(zstep) == IS_STRING && is_numeric_string(Z_STRVAL_P(zstep), Z_STRLEN_P(zstep), NULL, NULL, 0) == IS_DOUBLE)
- ) {
+ if (Z_TYPE_P(zstep) == IS_DOUBLE) {
is_step_double = 1;
+ } else if (Z_TYPE_P(zstep) == IS_STRING) {
+ int type = is_numeric_string(Z_STRVAL_P(zstep), Z_STRLEN_P(zstep), NULL, NULL, 0);
+ if (type == IS_DOUBLE) {
+ is_step_double = 1;
+ }
+ if (type == 0) {
+ /* bad number */
+ php_error_docref(NULL, E_WARNING, "Invalid range string - must be numeric");
+ RETURN_FALSE;
+ }
}
step = zval_get_double(zstep);
@@ -2242,6 +2250,10 @@ long_str:
}
lstep = step;
+ if (step <= 0) {
+ err = 1;
+ goto err;
+ }
Z_TYPE_INFO(tmp) = IS_LONG;
if (low > high) { /* Negative steps */