[macruby-changes] [3775] MacRuby/trunk/array.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 16 16:07:42 PDT 2010
Revision: 3775
http://trac.macosforge.org/projects/ruby/changeset/3775
Author: martinlagardette at apple.com
Date: 2010-03-16 16:07:41 -0700 (Tue, 16 Mar 2010)
Log Message:
-----------
#rindex: don't lookup param in an empty array
- Fixes 7692217
Modified Paths:
--------------
MacRuby/trunk/array.c
Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c 2010-03-16 22:41:08 UTC (rev 3774)
+++ MacRuby/trunk/array.c 2010-03-16 23:07:41 UTC (rev 3775)
@@ -896,10 +896,12 @@
else {
VALUE val;
rb_scan_args(argc, argv, "01", &val);
-
- size_t pos = rary_rindex_of_item(ary, RARY(ary)->len - 1, val);
- if (pos != NOT_FOUND) {
- return LONG2NUM(pos);
+
+ if (RARY(ary)->len > 0) {
+ size_t pos = rary_rindex_of_item(ary, RARY(ary)->len - 1, val);
+ if (pos != NOT_FOUND) {
+ return LONG2NUM(pos);
+ }
}
}
return Qnil;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100316/39e768ba/attachment.html>
More information about the macruby-changes
mailing list