mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fix a pontential buffer overflow when allocating a SILWitnessTable object.
Swift SVN r12719
This commit is contained in:
@@ -27,8 +27,10 @@ using namespace swift;
|
||||
SILWitnessTable *SILWitnessTable::create(SILModule &M,
|
||||
NormalProtocolConformance *Conformance,
|
||||
ArrayRef<SILWitnessTable::Entry> entries) {
|
||||
void *buf = M.allocate(sizeof(SILWitnessTable)
|
||||
+ sizeof(Entry) * (entries.size()-1),
|
||||
// FIXME: Is it valid to get an empty array ?
|
||||
size_t AdditionalEntriesSize =
|
||||
entries.empty() ? 0 : sizeof(Entry) * (entries.size()-1);
|
||||
void *buf = M.allocate(sizeof(SILWitnessTable) + AdditionalEntriesSize,
|
||||
alignof(SILWitnessTable));
|
||||
SILWitnessTable *wt = ::new (buf) SILWitnessTable(Conformance, entries);
|
||||
M.witnessTables.push_back(wt);
|
||||
|
||||
Reference in New Issue
Block a user