From 9dd3e8be8affbfadede2e13fab64e15551f4f187 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 17 Nov 2021 18:43:39 +0300 Subject: [PATCH] JIT: Fixed memory leak in Zend/tests/concat_002.phpt introduced by fac78ee760d04414abae571a28751de61a1c5b8c --- ext/opcache/jit/zend_jit_helpers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index dc742a31e9a..dafb648ea60 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1369,10 +1369,13 @@ static void ZEND_FASTCALL zend_jit_fast_assign_concat_helper(zval *op1, zval *op do { if (Z_REFCOUNTED_P(op1)) { - if (GC_REFCOUNT(Z_STR_P(op1)) == 1 && EXPECTED(Z_STR_P(op1) != Z_STR_P(op2))) { + if (GC_REFCOUNT(Z_STR_P(op1)) == 1) { result_str = perealloc(Z_STR_P(op1), ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(result_len)), 0); ZSTR_LEN(result_str) = result_len; zend_string_forget_hash_val(result_str); + if (UNEXPECTED(Z_STR_P(op1) == Z_STR_P(op2))) { + ZVAL_NEW_STR(op2, result_str); + } break; } GC_DELREF(Z_STR_P(op1));