avoid crash when parsing certain abstract classes which declare no methods

This commit is contained in:
Joel Dice 2012-01-13 16:51:39 -07:00
parent 0aa5755187
commit 929315e1f2

View File

@ -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);