From b06f294860a0cbbe59ef9ec7b6b602db3de64031 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 5 Nov 2024 07:53:20 -0500 Subject: [PATCH] Ensure that String(::Memory) returns only a String, not any owner (#56438) Fixes #56435 (cherry picked from commit 50ad4d96847c4a8153bc9435056d8d5e70e99716) --- src/genericmemory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/genericmemory.c b/src/genericmemory.c index ea52fca66ba48..b36852d53f9c8 100644 --- a/src/genericmemory.c +++ b/src/genericmemory.c @@ -197,7 +197,7 @@ JL_DLLEXPORT jl_value_t *jl_genericmemory_to_string(jl_genericmemory_t *m, size_ if (how != 0) { jl_value_t *o = jl_genericmemory_data_owner_field(m); jl_genericmemory_data_owner_field(m) = NULL; - if (how == 3 && + if (how == 3 && jl_is_string(o) && ((mlength + sizeof(void*) + 1 <= GC_MAX_SZCLASS) == (len + sizeof(void*) + 1 <= GC_MAX_SZCLASS))) { if (jl_string_data(o)[len] != '\0') jl_string_data(o)[len] = '\0';