@@ -1540,7 +1540,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
1540
1540
s = zend_string_init (Z_STRVAL_P (str ), Z_STRLEN_P (str ), 0 );
1541
1541
ZSTR_H (s ) = ZSTR_H (Z_STR_P (str ));
1542
1542
if (Z_REFCOUNTED_P (str )) {
1543
- zend_string_release_ex (Z_STR_P (str ), 0 );
1543
+ GC_DELREF (Z_STR_P (str ));
1544
1544
}
1545
1545
ZVAL_NEW_STR (str , s );
1546
1546
}
@@ -1552,7 +1552,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
1552
1552
* Temporarily increase the refcount to detect this situation. */
1553
1553
GC_ADDREF (s );
1554
1554
offset = zend_check_string_offset (dim , BP_VAR_W EXECUTE_DATA_CC );
1555
- if (GC_DELREF (s ) == 0 ) {
1555
+ if (UNEXPECTED ( GC_DELREF (s ) == 0 ) ) {
1556
1556
zend_string_efree (s );
1557
1557
if (UNEXPECTED (RETURN_VALUE_USED (opline ))) {
1558
1558
ZVAL_NULL (EX_VAR (opline -> result .var ));
@@ -1592,8 +1592,11 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
1592
1592
}
1593
1593
/* Convert to string, just the time to pick the 1st byte */
1594
1594
tmp = zval_try_get_string_func (value );
1595
- if (GC_DELREF (s ) == 0 ) {
1595
+ if (UNEXPECTED ( GC_DELREF (s ) == 0 ) ) {
1596
1596
zend_string_efree (s );
1597
+ if (tmp ) {
1598
+ zend_string_release_ex (tmp , 0 );
1599
+ }
1597
1600
if (UNEXPECTED (RETURN_VALUE_USED (opline ))) {
1598
1601
ZVAL_NULL (EX_VAR (opline -> result .var ));
1599
1602
}
@@ -1628,7 +1631,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
1628
1631
* Temporarily increase the refcount to detect this situation. */
1629
1632
GC_ADDREF (s );
1630
1633
zend_error (E_WARNING , "Only the first byte will be assigned to the string offset" );
1631
- if (GC_DELREF (s ) == 0 ) {
1634
+ if (UNEXPECTED ( GC_DELREF (s ) == 0 ) ) {
1632
1635
zend_string_efree (s );
1633
1636
if (UNEXPECTED (RETURN_VALUE_USED (opline ))) {
1634
1637
ZVAL_NULL (EX_VAR (opline -> result .var ));
@@ -2439,11 +2442,11 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
2439
2442
case IS_UNDEF :
2440
2443
/* The string may be destroyed while throwing the notice.
2441
2444
* Temporarily increase the refcount to detect this situation. */
2442
- if (!(GC_FLAGS (str ) & IS_ARRAY_IMMUTABLE )) {
2445
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED )) {
2443
2446
GC_ADDREF (str );
2444
2447
}
2445
2448
ZVAL_UNDEFINED_OP2 ();
2446
- if (!(GC_FLAGS (str ) & IS_ARRAY_IMMUTABLE ) && GC_DELREF (str ) == 0 ) {
2449
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED ) && UNEXPECTED ( GC_DELREF (str ) == 0 ) ) {
2447
2450
zend_string_efree (str );
2448
2451
ZVAL_NULL (result );
2449
2452
return ;
@@ -2455,11 +2458,11 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
2455
2458
if (type != BP_VAR_IS ) {
2456
2459
/* The string may be destroyed while throwing the notice.
2457
2460
* Temporarily increase the refcount to detect this situation. */
2458
- if (!(GC_FLAGS (str ) & IS_ARRAY_IMMUTABLE )) {
2461
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED )) {
2459
2462
GC_ADDREF (str );
2460
2463
}
2461
2464
zend_error (E_WARNING , "String offset cast occurred" );
2462
- if (!(GC_FLAGS (str ) & IS_ARRAY_IMMUTABLE ) && GC_DELREF (str ) == 0 ) {
2465
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED ) && UNEXPECTED ( GC_DELREF (str ) == 0 ) ) {
2463
2466
zend_string_efree (str );
2464
2467
ZVAL_NULL (result );
2465
2468
return ;
0 commit comments