Revision
3074
Author
emoy@apple.com
Date
2009-12-03 18:40:54 -0800 (Thu, 03 Dec 2009)

Log Message

Fix crash:
    macruby -e 'NSArray.arrayWithObject("a").addObject("b")'
due to backtrace failing, and returning Qnil, which was previous passed to
RSTRING_PTR.

Modified Paths

Diff

Modified: MacRuby/trunk/vm.cpp (3073 => 3074)


--- MacRuby/trunk/vm.cpp	2009-12-03 11:07:07 UTC (rev 3073)
+++ MacRuby/trunk/vm.cpp	2009-12-04 02:40:54 UTC (rev 3074)
@@ -3573,7 +3573,7 @@
     VALUE bt = rb_vm_call(exc, sel_registerName("backtrace"), 0, NULL,
 	    false);
 
-    const long count = RARRAY_LEN(bt);
+    const long count = (bt != Qnil ? RARRAY_LEN(bt) : 0);
     if (count > 0) {
 	for (long i = 0; i < count; i++) {
 	    const char *bte = RSTRING_PTR(RARRAY_AT(bt, i));