[].pack("P") $B$G(B SEGV

rucila とç?³ã?まã?ã??

Array#pack の “P” でé?å??のé?·ã?ã?足ã??なã?æ??に SEGV ã?ç?ºç??ã?ã??ã?とã?
ã?ã??まã?ã??
ç?°å¢?ã??ã?¹ã?¯ã?ªã??ã??にã??ってはå?¥ã®ã?¨ã?©ã?¼ã?ç?ºç??ã?まã?ã?ã?
ã?¨ã?©ã?¼å??容ã? “too few argument” でなã?ã??のになã??まã?ã??

% ruby -v
ruby 1.8.4 (2005-12-24) [i686-linux]
% ruby
[].pack(“P”)
-:1:in `pack’: can’t convert false into String (TypeError)
from -:1

ã?ぶã??ã?ã?だとæ?ã?まã?ã??

Index: pack.c

RCS file: /src/ruby/pack.c,v
retrieving revision 1.86
diff -u -r1.86 pack.c
— pack.c 18 Jul 2006 07:02:35 -0000 1.86
+++ pack.c 3 Aug 2006 15:20:28 -0000
@@ -454,7 +454,7 @@
items = RARRAY(ary)->len;
idx = 0;

-#define THISFROM RARRAY(ary)->ptr[idx]
+#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] :
(rb_raise(rb_eArgError, toofew), 0))
#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] :
(rb_raise(rb_eArgError, “too few arguments”),0))

   while (p < pend) {

[email protected]$G$9!#e(B

At Fri, 4 Aug 2006 00:44:49 +0900,
rucila wrote in [ruby-dev:29182]:

-#define THISFROM RARRAY(ary)->ptr[idx]
+#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : (rb_raise(rb_eArgError, toofew), 0))
#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : (rb_raise(rb_eArgError, “too few arguments”),0))

toofewe$B$,L$Dj5A$G$9!#e(B

Index: pack.c

RCS file: /cvs/ruby/src/ruby/pack.c,v
retrieving revision 1.86
diff -p -U 2 -r1.86 pack.c
— pack.c 18 Jul 2006 07:02:35 -0000 1.86
+++ pack.c 3 Aug 2006 16:13:00 -0000
@@ -455,6 +455,7 @@ pack_pack(VALUE ary, VALUE fmt)
idx = 0;

-#define THISFROM RARRAY(ary)->ptr[idx]
-#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] :
(rb_raise(rb_eArgError, “too few arguments”),0))
+#define TOO_FEW (rb_raise(rb_eArgError, “too few arguments”), 0)
+#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : TOO_FEW)
+#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : TOO_FEW)

 while (p < pend) {

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29183] Re: [].pack(“P”) e$B$Ge(B SEGV”
on Fri, 4 Aug 2006 01:18:03 +0900, [email protected] writes:

|At Fri, 4 Aug 2006 00:44:49 +0900,
|rucila wrote in [ruby-dev:29182]:
|> -#define THISFROM RARRAY(ary)->ptr[idx]
|> +#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : (rb_raise(rb_eArgError, toofew), 0))
|> #define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : (rb_raise(rb_eArgError, “too few arguments”),0))
|
|toofewe$B$,L$Dj5A$G$9!#e(B

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs