summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-21 05:39:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-21 05:39:19 +0000
commitedbe98d848e4872654bb5273a6a8250492026c18 (patch)
tree9d9e68c491b333a85b01f36f74935e98f873b043 /pack.c
parent9402cbeec54f5a4de56588a1b980f53e5d50c04e (diff)
* 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
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c26
1 files changed, 20 insertions, 6 deletions
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] == '*')
@@ -1053,6 +1054,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;