Skip to content

Commit

Permalink
FIXED: Memory leak in PL_get_wchars() when using BUF_MALLOC.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Oct 3, 2024
1 parent f017d92 commit 279e2ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pl-fli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,14 +1819,20 @@ bool
PL_get_wchars(term_t l, size_t *length, pl_wchar_t **s, unsigned flags)
{ GET_LD
PL_chars_t text;
buf_mark_t mark;

valid_term_t(l);
if ( (flags&BUF_MALLOC) )
PL_mark_string_buffers(&mark);

if ( !PL_get_text(l, &text, flags) )
return false;

PL_promote_text(&text);
PL_save_text(&text, flags);

if ( (flags&BUF_MALLOC) )
PL_release_string_buffers_from_mark(mark);

if ( length )
*length = text.length;
*s = text.text.w;
Expand Down

0 comments on commit 279e2ed

Please sign in to comment.