From a0c4bb8f64e903054566b1312b6011da0ffc8bd5 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:06:22 +0200 Subject: [PATCH] Fix soap crash with ZEND_RC_DEBUG --- ext/soap/php_sdl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 53c727501fb1d..8d5a5b28cb8fb 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -154,7 +154,13 @@ encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type) new_enc->details.type_str = estrdup(new_enc->details.type_str); } if (new_enc->details.clark_notation) { - zend_string_addref(new_enc->details.clark_notation); + /* If it was persistent or becomes persistent, we must dup. Otherwise we can copy. */ + bool was_persistent = GC_FLAGS(new_enc->details.clark_notation) & IS_STR_PERSISTENT; + if (was_persistent || sdl->is_persistent) { + new_enc->details.clark_notation = zend_string_dup(new_enc->details.clark_notation, sdl->is_persistent); + } else { + zend_string_addref(new_enc->details.clark_notation); + } } if (sdl->encoders == NULL) { sdl->encoders = pemalloc(sizeof(HashTable), sdl->is_persistent);