We were writing a pointer to a selector string into the contents of a
string instead of overwriting the pointer to the string, leading to
corruption. This was causing non-deterministic failures of the
'trivial-objc-methods' test case.
Differential Revision: https://reviews.llvm.org/D112671
if (auto Err = validatePointerSectionExtent("__objc_selrefs", ObjCSelRefs))
return Err;
- for (uintptr_t SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
+ for (uintptr_t &SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
const char *SelName = reinterpret_cast<const char *>(SelEntry);
auto Sel = sel_registerName(SelName);
- *reinterpret_cast<SEL *>(SelEntry) = Sel;
+ *reinterpret_cast<SEL *>(&SelEntry) = Sel;
}
}