diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-05-31 13:02:35 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-05-31 13:02:35 -0700 |
commit | 3ce2f2dcf8b8818926519f5f2652d1f6914eae2c (patch) | |
tree | ca6b87b8b35b18c2d5bc1be4e5f717ab97dde2a9 /stream.c | |
parent | b2a3bbde854cb1b46ff84e6cf9f8219c727d42c4 (diff) | |
download | txr-3ce2f2dcf8b8818926519f5f2652d1f6914eae2c.tar.gz txr-3ce2f2dcf8b8818926519f5f2652d1f6914eae2c.tar.bz2 txr-3ce2f2dcf8b8818926519f5f2652d1f6914eae2c.zip |
streams: regression: gc issue in get_string_from_stream.
* stream.c (get_string_from_stream_common): The so->buf = 0
assignment must precede the call to string_own(buf), because
the string out stream object may already be garbage, and
the string_own call will reclaim it. If we don't null out
the buffer, the string will get ownership of a freed buffer.
This reproduced in the CSV test case on MacOS Lion, 32 bit x86.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2724,8 +2724,8 @@ val get_string_from_stream_common(val stream, val copy_p_in) if (waste >= 128 && so->size - so->len > so->len / 4) buf = coerce(wchar_t *, chk_realloc(coerce(mem_t *, so->buf), (so->len + 1) * sizeof *so->buf)); - out = string_own(buf); so->buf = 0; + out = string_own(buf); } return out; |