]> granicus.if.org Git - php/commitdiff
Fix php_splice() to work with large values
authorZeev Suraski <zeev@php.net>
Fri, 1 Mar 2002 12:00:05 +0000 (12:00 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 1 Mar 2002 12:00:05 +0000 (12:00 +0000)
ext/standard/array.c

index d80ac32507e7683200ae5e83d9594eb3408c2843..106ea8d23fea0647d3dbdb2ee5e1f701f285707f 100644 (file)
@@ -1529,7 +1529,17 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length,
                   and copy it into the output hash */
                for (i=0; i<list_count; i++) {
                        entry = *list[i];
-                       entry->refcount++;
+                       if (entry->refcount>=1000) {
+                               zval *tmp = (zval *) emalloc(sizeof(zval));
+
+                               *tmp = *entry;
+                               zval_copy_ctor(tmp);
+                               tmp->refcount = 1;
+                               tmp->is_ref = 0;
+                               entry = tmp;
+                       } else {
+                               entry->refcount++;
+                       }
                        zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
                }
        }