summaryrefslogtreecommitdiff
path: root/ext/zlib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-10 12:50:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-10 12:50:26 +0000
commit498b6f477631681b52460a9aa9dc2b4c837cd1e8 (patch)
tree6603d40b1afae7c7e62b04ae0cf2d2ba99fcacf1 /ext/zlib
parent41bd073de21289b7de03c1c48258ddd2d17a1d0c (diff)
zlib.c: GC guards
* ext/zlib/zlib.c: prevent from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/zlib.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index a3a8c33..d5a18dd 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1029,7 +1029,7 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
{
struct zstream_run_args args;
int err;
- volatile VALUE guard = Qnil;
+ VALUE guard = Qnil;
args.z = z;
args.flush = flush;
@@ -1086,7 +1086,7 @@ loop:
if (z->stream.avail_in > 0) {
zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
- RB_GC_GUARD(guard) = Qnil; /* prevent tail call to make guard effective */
+ RB_GC_GUARD(guard); /* prevent tail call to make guard effective */
}
if (args.jump_state)
@@ -2672,7 +2672,7 @@ gzfile_write(struct gzfile *gz, Bytef *str, long len)
static long
gzfile_read_more(struct gzfile *gz)
{
- volatile VALUE str;
+ VALUE str;
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
str = gzfile_read_raw(gz);
@@ -2685,6 +2685,7 @@ gzfile_read_more(struct gzfile *gz)
if (RSTRING_LEN(str) > 0) { /* prevent Z_BUF_ERROR */
zstream_run(&gz->z, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str),
Z_SYNC_FLUSH);
+ RB_GC_GUARD(str);
}
if (gz->z.buf_filled > 0) break;
}
@@ -2791,6 +2792,7 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
if (!NIL_P(outbuf)) {
rb_str_resize(outbuf, RSTRING_LEN(dst));
memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
+ RB_GC_GUARD(dst);
dst = outbuf;
}
OBJ_TAINT(dst); /* for safe */
@@ -3583,6 +3585,7 @@ rb_gzwriter_write(VALUE obj, VALUE str)
str = rb_str_conv_enc(str, rb_enc_get(str), gz->enc2);
}
gzfile_write(gz, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str));
+ RB_GC_GUARD(str);
return INT2FIX(RSTRING_LEN(str));
}
@@ -3956,6 +3959,7 @@ rb_gzreader_ungetc(VALUE obj, VALUE s)
s = rb_str_conv_enc(s, rb_enc_get(s), gz->enc2);
}
gzfile_ungets(gz, (const Bytef*)RSTRING_PTR(s), RSTRING_LEN(s));
+ RB_GC_GUARD(s);
return Qnil;
}
@@ -4035,7 +4039,7 @@ static VALUE
gzreader_gets(int argc, VALUE *argv, VALUE obj)
{
struct gzfile *gz = get_gzfile(obj);
- volatile VALUE rs;
+ VALUE rs;
VALUE dst;
const char *rsptr;
char *p, *res;
@@ -4154,6 +4158,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
if (rspara) {
gzreader_skip_linebreaks(gz);
}
+ RB_GC_GUARD(rs);
return gzfile_newstr(gz, dst);
}