File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -2383,11 +2383,20 @@ static void initClassVTable(ClassMetadata *self) {
2383
2383
// Calculate the base method's vtable offset from the
2384
2384
// base method descriptor. The offset will be relative
2385
2385
// to the base class's vtable start offset.
2386
- auto baseClassMethods = baseClass->getMethodDescriptors ().data ();
2387
- auto offset = baseMethod - baseClassMethods;
2386
+ auto baseClassMethods = baseClass->getMethodDescriptors ();
2387
+
2388
+ // If the method descriptor doesn't land within the bounds of the
2389
+ // method table, abort.
2390
+ if (baseMethod < baseClassMethods.begin () ||
2391
+ baseMethod >= baseClassMethods.end ()) {
2392
+ fatalError (0 , " resilient vtable at %p contains out-of-bounds "
2393
+ " method descriptor %p\n " ,
2394
+ overrideTable, baseMethod);
2395
+ }
2388
2396
2389
2397
// Install the method override in our vtable.
2390
2398
auto baseVTable = baseClass->getVTableDescriptor ();
2399
+ auto offset = baseMethod - baseClassMethods.data ();
2391
2400
classWords[baseVTable->getVTableOffset (baseClass) + offset]
2392
2401
= descriptor.Impl .get ();
2393
2402
}
You can’t perform that action at this time.
0 commit comments