diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-09 17:45:53 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-09 17:45:53 +0000 |
commit | 90a88ab9a09d19165cf3668b6a8473024e064fa7 (patch) | |
tree | e11fe4e2ab597cf512b2fd680b50c91cc0293a08 /pack.c | |
parent | 80549d5f17e09173251204f08d288a71bad39256 (diff) |
* marshal.c (r_object0): remove unnecessary iv restoration for
USRMARSHAL. [ruby-dev:21582]
* marshal.c (w_object): dump generic instance variables from
a string from '_dump'.
* variable.c (rb_generic_ivar_table): return 0 if obj's FL_EXIVAR
is not set.
* time.c (time_dump): copy instance variables to dumped string, to
be included in the marshaled data.
* bignum.c (rb_big2ulong): add range check to ensure round trip.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -825,7 +825,7 @@ pack_pack(ary, fmt) case 'U': while (len-- > 0) { - unsigned long l; + long l; char buf[8]; int le; @@ -834,6 +834,9 @@ pack_pack(ary, fmt) else { l = NUM2ULONG(from); } + if (l < 0) { + rb_raise(rb_eArgError, "pack(U): negative value"); + } le = uv_to_utf8(buf, l); rb_str_buf_cat(res, (char*)buf, le); } @@ -918,7 +921,11 @@ pack_pack(ary, fmt) if (NIL_P(from)) ul = 0; else { - ul = NUM2ULONG(from); + long l = NUM2LONG(from); + if (l < 0) { + rb_raise(rb_eArgError, "cannot compress negative numbers"); + } + ul = l; } while (ul) { @@ -1857,7 +1864,7 @@ uv_to_utf8(buf, uv) buf[5] = (uv&0x3f)|0x80; return 6; } - rb_raise(rb_eArgError, "uv_to_utf8(); value out of range"); + rb_raise(rb_eArgError, "pack(U): value out of range"); } static const long utf8_limits[] = { |