diff --git a/ext/src/swow_buffer.c b/ext/src/swow_buffer.c index 7f857d04..ab855d0d 100644 --- a/ext/src/swow_buffer.c +++ b/ext/src/swow_buffer.c @@ -1026,9 +1026,11 @@ static char *swow_buffer_realloc_standard(char *old_value, size_t new_size) zend_string_forget_hash_val(new_string); } else { new_string = zend_string_alloc(new_size, false); - memcpy(ZSTR_VAL(new_string), ZSTR_VAL(old_string), new_length); - if (old_string != NULL && !ZSTR_IS_INTERNED(old_string)) { - GC_DELREF(old_string); + if (old_string != NULL) { + memcpy(ZSTR_VAL(new_string), ZSTR_VAL(old_string), new_length); + if (!ZSTR_IS_INTERNED(old_string)) { + GC_DELREF(old_string); + } } } ZSTR_VAL(new_string)[ZSTR_LEN(new_string) = new_length] = '\0';