summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/zlib/zlib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 15f90681f8..b05e5264c5 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -709,6 +709,7 @@ zstream_run(z, src, len, flush)
{
uInt n;
int err;
+ volatile VALUE guard;
if (NIL_P(z->input) && len == 0) {
z->stream.next_in = "";
@@ -718,6 +719,10 @@ zstream_run(z, src, len, flush)
zstream_append_input(z, src, len);
z->stream.next_in = RSTRING(z->input)->ptr;
z->stream.avail_in = RSTRING(z->input)->len;
+ /* keep reference to `z->input' so as not to be garbage collected
+ after zstream_reset_input() and prevent `z->stream.next_in'
+ from dangling. */
+ guard = z->input;
}
if (z->stream.avail_out == 0) {