From 41ef2952c866e34a51185d26b1e105016e9c5108 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 19 Jan 2018 13:41:35 +0300 Subject: [PATCH] Only persistent referencecounted strings should be duplicated. --- ext/standard/browscap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index e58a20cd4d..60c012707d 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -688,7 +688,17 @@ static int browser_reg_compare( static void browscap_zval_copy_ctor(zval *p) /* {{{ */ { - zval_copy_ctor(p); + if (Z_REFCOUNTED_P(p)) { + zend_string *str; + + ZEND_ASSERT(Z_TYPE_P(p) == IS_STRING); + str = Z_STR_P(p); + if (!(GC_FLAGS(str) & GC_PERSISTENT)) { + GC_ADDREF(str); + } else { + ZVAL_NEW_STR(p, zend_string_init(ZSTR_VAL(str), ZSTR_LEN(str), 0)); + } + } } /* }}} */ -- 2.50.1