mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed refcount handling
This commit is contained in:
parent
2a82660923
commit
0680cdb4ac
@ -1639,7 +1639,9 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
|
||||
}
|
||||
|
||||
if (result) {
|
||||
Z_ADDREF_P(result);
|
||||
if (Z_REFCOUNTED_P(result)) {
|
||||
Z_ADDREF_P(result);
|
||||
}
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return FAILURE;
|
||||
|
@ -284,7 +284,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
|
||||
new_op_array = NULL;
|
||||
zend_file_handle_dtor(&file_handle TSRMLS_CC);
|
||||
}
|
||||
STR_FREE(opened_path);
|
||||
STR_RELEASE(opened_path);
|
||||
if (new_op_array) {
|
||||
EG(active_op_array) = new_op_array;
|
||||
if (!EG(active_symbol_table)) {
|
||||
|
@ -440,49 +440,52 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
}
|
||||
Z_ADDREF_P(value);
|
||||
if (Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
zend_hash_next_index_insert(ht, value);
|
||||
return;
|
||||
}
|
||||
switch(Z_TYPE_P(offset)) {
|
||||
case IS_STRING:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
zend_symtable_update(ht, Z_STR_P(offset), value);
|
||||
return;
|
||||
case IS_DOUBLE:
|
||||
case IS_RESOURCE:
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
}
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
case IS_STRING:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
}
|
||||
zend_symtable_update(ht, Z_STR_P(offset), value);
|
||||
return;
|
||||
}
|
||||
if (offset->type == IS_DOUBLE) {
|
||||
index = (long)Z_DVAL_P(offset);
|
||||
} else {
|
||||
index = Z_LVAL_P(offset);
|
||||
}
|
||||
Z_ADDREF_P(value);
|
||||
zend_hash_index_update(ht, index, value);
|
||||
return;
|
||||
case IS_NULL:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
case IS_DOUBLE:
|
||||
case IS_RESOURCE:
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
}
|
||||
if (offset->type == IS_DOUBLE) {
|
||||
index = (long)Z_DVAL_P(offset);
|
||||
} else {
|
||||
index = Z_LVAL_P(offset);
|
||||
}
|
||||
zend_hash_index_update(ht, index, value);
|
||||
return;
|
||||
case IS_NULL:
|
||||
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||
if (ht->nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
}
|
||||
zend_hash_next_index_insert(ht, value);
|
||||
return;
|
||||
default:
|
||||
zend_error(E_WARNING, "Illegal offset type");
|
||||
return;
|
||||
}
|
||||
Z_ADDREF_P(value);
|
||||
zend_hash_next_index_insert(ht, value);
|
||||
return;
|
||||
default:
|
||||
zend_error(E_WARNING, "Illegal offset type");
|
||||
return;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
|
@ -119,7 +119,7 @@ static void spl_ptr_llist_zval_dtor(spl_ptr_llist_element *elem TSRMLS_DC) { /*
|
||||
|
||||
static void spl_ptr_llist_zval_ctor(spl_ptr_llist_element *elem TSRMLS_DC) { /* {{{ */
|
||||
if (Z_REFCOUNTED(elem->data)) {
|
||||
Z_ADDREF_P(&elem->data);
|
||||
Z_ADDREF(elem->data);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -527,7 +527,9 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp TSRML
|
||||
next = current->next;
|
||||
|
||||
add_index_zval(&dllist_array, i, ¤t->data);
|
||||
Z_ADDREF_P(¤t->data);
|
||||
if (Z_REFCOUNTED(current->data)) {
|
||||
Z_ADDREF(current->data);
|
||||
}
|
||||
i++;
|
||||
|
||||
current = next;
|
||||
@ -1234,7 +1236,9 @@ SPL_METHOD(SplDoublyLinkedList, add)
|
||||
return;
|
||||
}
|
||||
|
||||
Z_ADDREF_P(value);
|
||||
if (Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
if (index == intern->llist->count) {
|
||||
/* If index is the last entry+1 then we do a push because we're not inserting before any entry */
|
||||
spl_ptr_llist_push(intern->llist, value TSRMLS_CC);
|
||||
|
@ -166,7 +166,9 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* {
|
||||
for (i = 0; i < intern->array->size; i++) {
|
||||
if (!ZVAL_IS_UNDEF(&intern->array->elements[i])) {
|
||||
zend_hash_index_update(ht, i, &intern->array->elements[i]);
|
||||
Z_ADDREF_P(&intern->array->elements[i]);
|
||||
if (Z_REFCOUNTED(intern->array->elements[i])){
|
||||
Z_ADDREF(intern->array->elements[i]);
|
||||
}
|
||||
} else {
|
||||
zend_hash_index_update(ht, i, &EG(uninitialized_zval));
|
||||
}
|
||||
@ -596,7 +598,9 @@ SPL_METHOD(SplFixedArray, __wakeup)
|
||||
spl_fixedarray_init(intern->array, size TSRMLS_CC);
|
||||
|
||||
for (zend_hash_internal_pointer_reset_ex(intern_ht, &ptr); (data = zend_hash_get_current_data_ex(intern_ht, &ptr)) != NULL; zend_hash_move_forward_ex(intern_ht, &ptr)) {
|
||||
Z_ADDREF_P(data);
|
||||
if (Z_REFCOUNTED_P(data)) {
|
||||
Z_ADDREF_P(data);
|
||||
}
|
||||
ZVAL_COPY_VALUE(&intern->array->elements[index++], data);
|
||||
}
|
||||
|
||||
@ -644,10 +648,11 @@ SPL_METHOD(SplFixedArray, toArray)
|
||||
for (; i < intern->array->size; i++) {
|
||||
if (!ZVAL_IS_UNDEF(&intern->array->elements[i])) {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), i, &intern->array->elements[i]);
|
||||
Z_ADDREF_P(&intern->array->elements[i]);
|
||||
if (Z_REFCOUNTED(intern->array->elements[i])) {
|
||||
Z_ADDREF(intern->array->elements[i]);
|
||||
}
|
||||
} else {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), i, &EG(uninitialized_zval));
|
||||
Z_ADDREF_P(&EG(uninitialized_zval));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1038,8 +1043,6 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Z_ADDREF_P(object);
|
||||
|
||||
iterator = emalloc(sizeof(spl_fixedarray_it));
|
||||
|
||||
zend_iterator_init((zend_object_iterator*)iterator TSRMLS_CC);
|
||||
|
@ -92,7 +92,9 @@ static void spl_ptr_heap_zval_dtor(zval *elem TSRMLS_DC) { /* {{{ */
|
||||
/* }}} */
|
||||
|
||||
static void spl_ptr_heap_zval_ctor(zval *elem TSRMLS_DC) { /* {{{ */
|
||||
Z_ADDREF_P(elem);
|
||||
if (Z_REFCOUNTED_P(elem)) {
|
||||
Z_ADDREF_P(elem);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -398,8 +400,8 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o
|
||||
int i;
|
||||
intern->heap = spl_ptr_heap_clone(other->heap TSRMLS_CC);
|
||||
for (i = 0; i < intern->heap->count; ++i) {
|
||||
if (!ZVAL_IS_UNDEF(&intern->heap->elements[i])) {
|
||||
Z_ADDREF_P(&intern->heap->elements[i]);
|
||||
if (Z_REFCOUNTED(intern->heap->elements[i])) {
|
||||
Z_ADDREF(intern->heap->elements[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -537,7 +539,9 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
|
||||
|
||||
for (i = 0; i < intern->heap->count; ++i) {
|
||||
add_index_zval(&heap_array, i, &intern->heap->elements[i]);
|
||||
Z_ADDREF_P(&intern->heap->elements[i]);
|
||||
if (Z_REFCOUNTED(intern->heap->elements[i])) {
|
||||
Z_ADDREF(intern->heap->elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pnstr = spl_gen_private_prop_name(ce, "heap", sizeof("heap")-1 TSRMLS_CC);
|
||||
@ -710,7 +714,9 @@ SPL_METHOD(SplPriorityQueue, extract)
|
||||
return;
|
||||
}
|
||||
|
||||
Z_ADDREF_P(value_out);
|
||||
if (Z_REFCOUNTED_P(value_out)) {
|
||||
Z_ADDREF_P(value_out);
|
||||
}
|
||||
zval_ptr_dtor(value);
|
||||
|
||||
RETURN_ZVAL(value_out, 1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user