From 929315e1f21235502416efd82976f39b952f02a9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 13 Jan 2012 16:51:39 -0700 Subject: [PATCH] avoid crash when parsing certain abstract classes which declare no methods --- src/machine.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index b4db6ac1fa..fbf8ca2511 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1673,13 +1673,17 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool) set(t, addendum, ClassAddendumMethodTable, classMethodTable(t, class_)); - unsigned oldLength = arrayLength(t, classMethodTable(t, class_)); + unsigned oldLength = classMethodTable(t, class_) ? + arrayLength(t, classMethodTable(t, class_)) : 0; + object newMethodTable = makeArray (t, oldLength + listSize(t, abstractVirtuals)); - memcpy(&arrayBody(t, newMethodTable, 0), - &arrayBody(t, classMethodTable(t, class_), 0), - oldLength * sizeof(object)); + if (oldLength) { + memcpy(&arrayBody(t, newMethodTable, 0), + &arrayBody(t, classMethodTable(t, class_), 0), + oldLength * sizeof(object)); + } mark(t, newMethodTable, ArrayBody, oldLength);