Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Zend/tests/gh21605.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
GH-21605: Missing addref for Countable::count()
--CREDITS--
cnwangjihe
--FILE--
<?php

class C implements Countable {
public function count(): int {
global $c;
$c = null;
var_dump($this);
return 42;
}
}

$c = new C;
var_dump(count($c));

?>
--EXPECTF--
object(C)#%d (0) {
}
int(42)
2 changes: 2 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);
EG(bailout) = &__bailout; \
if (SETJMP(__bailout)==0) {
#define zend_catch \
ZEND_ASSERT(EG(bailout) == &__bailout); \
} else { \
ZEND_ASSERT(EG(bailout) == &__bailout); \
EG(bailout) = __orig_bailout;
#define zend_end_try() \
} \
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -9580,7 +9580,9 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMP|CV, UNUSED)
zval retval;

zend_function *count_fn = zend_hash_find_ptr(&zobj->ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
GC_ADDREF(zobj);
zend_call_known_instance_method_with_0_params(count_fn, zobj, &retval);
OBJ_RELEASE(zobj);
count = zval_get_long(&retval);
zval_ptr_dtor(&retval);
break;
Expand Down
12 changes: 12 additions & 0 deletions Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5218,7 +5218,7 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
&& ssa->vars[ssa_op->op2_def].use_chain < 0
&& !ssa->vars[ssa_op->op2_def].phi_use_chain) {
if (!zend_jit_store_type(&ctx, var_num, type)) {
return 0;
goto jit_failure;
}
SET_STACK_TYPE(stack, var_num, type, 1);
}
Expand Down Expand Up @@ -5271,7 +5271,7 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
&& ssa->vars[ssa_op->op1_def].use_chain < 0
&& !ssa->vars[ssa_op->op1_def].phi_use_chain) {
if (!zend_jit_store_type(&ctx, var_num, type)) {
return 0;
goto jit_failure;
}
SET_STACK_TYPE(stack, var_num, type, 1);
}
Expand Down Expand Up @@ -5368,7 +5368,7 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
&& ssa->vars[ssa_op->op1_def].use_chain < 0
&& !ssa->vars[ssa_op->op1_def].phi_use_chain) {
if (!zend_jit_store_type(&ctx, var_num, type)) {
return 0;
goto jit_failure;
}
SET_STACK_TYPE(stack, var_num, type, 1);
}
Expand Down Expand Up @@ -6627,7 +6627,7 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
var_num = EX_VAR_TO_NUM(var_num);

if (!zend_jit_store_type(&ctx, var_num, type)) {
return 0;
goto jit_failure;
}
SET_STACK_TYPE(stack, var_num, type, 1);
}
Expand Down Expand Up @@ -7266,7 +7266,7 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
&& type != STACK_MEM_TYPE(stack, i)
&& zend_jit_trace_must_store_type(op_array, op_array_ssa, opline - op_array->opcodes, i, type)) {
if (!zend_jit_store_type(jit, i, type)) {
return 0;
goto jit_failure;
}
SET_STACK_TYPE(stack, i, type, 1);
}
Expand Down Expand Up @@ -7387,11 +7387,11 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
zend_string_release(name);
}

jit_cleanup:;
} zend_catch {
do_bailout = 1;
} zend_end_try();

jit_cleanup:
/* Clean up used op_arrays */
while (num_op_arrays > 0) {
op_array = op_arrays[--num_op_arrays];
Expand Down
36 changes: 0 additions & 36 deletions php-8.3.30.manifest

This file was deleted.