]> granicus.if.org Git - php/commitdiff
Fixed a bug in preg_split.
authorAndrey Hristov <andrey@php.net>
Wed, 9 Jun 1999 21:13:05 +0000 (21:13 +0000)
committerAndrey Hristov <andrey@php.net>
Wed, 9 Jun 1999 21:13:05 +0000 (21:13 +0000)
Fixed a bug in array_shift/array_pop.

ext/pcre/pcre.c
ext/standard/basic_functions.c

index eb91b954a1b97c42baf7f46b2f7d4c3e641ba94b..39662be2ecfb4b0c350c0a0acdde8c59c3b9e5b9 100644 (file)
@@ -829,9 +829,9 @@ PHP_FUNCTION(preg_split)
                                limit_val--;
                }
                else { /* if no match */
-                       /* Add the last piece to the return value, if there
-                          were matches before */
-                       if (piece > subject->value.str.val)
+                       /* Add the last piece to the return value, if there is
+                          something left */
+                       if (limit != 0)
                                add_next_index_stringl(return_value,
                                                                           piece,
                                                                           subject_end-piece, 1);
index e37fcbc74165891d0ea666e07a336c19af912065..43bc22b0c38c194a421f55d1bdf5d456989296f3 100644 (file)
@@ -2583,7 +2583,11 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
                zend_error(E_WARNING, "The argument needs to be an array");
                return;
        }
-       
+
+       if (zend_hash_num_elements(stack->value.ht) == 0) {
+               return;
+       }
+               
        /* Get the first or last value and copy it into the return value */
        if (off_the_end)
                zend_hash_internal_pointer_end(stack->value.ht);