Skip to content

Commit

Permalink
Ensure that String(::Memory) returns only a String, not any owner (#5…
Browse files Browse the repository at this point in the history
…6438)

Fixes #56435

(cherry picked from commit 50ad4d9)
  • Loading branch information
vtjnash authored and KristofferC committed Nov 11, 2024
1 parent 0baca20 commit b06f294
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/genericmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit b06f294

Please sign in to comment.