[macruby-changes] [5026] MacRuby/trunk/vm.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 14 18:41:43 PST 2010
Revision: 5026
http://trac.macosforge.org/projects/ruby/changeset/5026
Author: lsansonetti at apple.com
Date: 2010-12-14 18:41:39 -0800 (Tue, 14 Dec 2010)
Log Message:
-----------
fix an assertion that could happen when calling #methods & friends on a class that contains a method name larger than 100 characters
Modified Paths:
--------------
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2010-12-14 11:36:02 UTC (rev 5025)
+++ MacRuby/trunk/vm.cpp 2010-12-15 02:41:39 UTC (rev 5026)
@@ -2236,12 +2236,14 @@
const char *selname = sel_getName(sel);
const size_t len = strlen(selname);
- char buf[100];
+ assert(len > 0);
+ char *buf = NULL;
const char *p = strchr(selname, ':');
if (p != NULL && strchr(p + 1, ':') == NULL) {
// remove trailing ':' for methods with arity 1
- assert(len < sizeof(buf));
+ buf = (char *)malloc(len);
+ assert(buf != NULL);
strncpy(buf, selname, len);
buf[len - 1] = '\0';
selname = buf;
@@ -2250,6 +2252,11 @@
ID mid = rb_intern(selname);
VALUE sym = ID2SYM(mid);
+ if (buf != NULL) {
+ free(buf);
+ buf = NULL;
+ }
+
if (rb_ary_includes(ary, sym) == Qfalse) {
int type = NOEX_PUBLIC;
if (flags & VM_METHOD_PRIVATE) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101214/32373c4a/attachment.html>
More information about the macruby-changes
mailing list