rucila
1
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) {
rucila
2
e$B$J$+$@$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) {
rucila
3
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$/$@$5$$!#e(B