From edbe98d848e4872654bb5273a6a8250492026c18 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 21 May 2002 05:39:19 +0000 Subject: * object.c (Init_Object): should do exact match for Module#==. * compar.c (cmp_eq): returns 'false' if <=> returns 'nil'. * compar.c (cmp_gt,cmp_ge,cmp_lt,cmp_le,cmp_between): ditto. * pack.c (pack_pack): should propagate taintedness. * pack.c (pack_unpack): ditto. * eval.c (rb_thread_schedule): need to preserve errno before calling rb_trap_exec(). * regex.c (calculate_must_string): a bug in charset/charset_not parsing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- pack.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index 67224af21a..60b44d4ba8 100644 --- a/pack.c +++ b/pack.c @@ -406,6 +406,7 @@ pack_pack(ary, fmt) StringValue(from); ptr = RSTRING(from)->ptr; plen = RSTRING(from)->len; + OBJ_INFECT(res, from); } if (p[-1] == '*') @@ -1052,6 +1053,18 @@ hex2num(c) #define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil) +static VALUE +infected_str_new(ptr, len, str) + const char *ptr; + long len; + VALUE str; +{ + VALUE s = rb_str_new(ptr, len); + + OBJ_INFECT(s, str); + return s; +} + static VALUE pack_unpack(str, fmt) VALUE str, fmt; @@ -1130,7 +1143,7 @@ pack_unpack(str, fmt) if (*t != ' ' && *t != '\0') break; t--; len--; } - rb_ary_push(ary, rb_str_new(s, len)); + rb_ary_push(ary, infected_str_new(s, len, str)); s += end; } break; @@ -1145,14 +1158,14 @@ pack_unpack(str, fmt) if (*t) break; t--; len--; } - rb_ary_push(ary, rb_str_new(s, len)); + rb_ary_push(ary, infected_str_new(s, len, str)); s += end; } break; case 'a': if (len > send - s) len = send - s; - rb_ary_push(ary, rb_str_new(s, len)); + rb_ary_push(ary, infected_str_new(s, len, str)); s += len; break; @@ -1478,7 +1491,7 @@ pack_unpack(str, fmt) case 'u': { - VALUE str = rb_str_new(0, (send - s)*3/4); + VALUE str = infected_str_new(0, (send - s)*3/4, str); char *ptr = RSTRING(str)->ptr; int total = 0; @@ -1534,7 +1547,7 @@ pack_unpack(str, fmt) case 'm': { - VALUE str = rb_str_new(0, (send - s)*3/4); + VALUE str = infected_str_new(0, (send - s)*3/4, str); char *ptr = RSTRING(str)->ptr; int a,b,c,d; static int first = 1; @@ -1577,7 +1590,7 @@ pack_unpack(str, fmt) case 'M': { - VALUE str = rb_str_new(0, send - s); + VALUE str = infected_str_new(0, send - s, str); char *ptr = RSTRING(str)->ptr; int c1, c2; @@ -1686,6 +1699,7 @@ pack_unpack(str, fmt) rb_raise(rb_eArgError, "non associated pointer"); } tmp = rb_str_new2(t); + OBJ_INFECT(tmp, str); } else { tmp = Qnil; -- cgit v1.2.3