Skip to content

Commit ee8447e

Browse files
committed
[Reflection] Reject BuiltinTypeDescriptors with non-power-of-two alignments.
rdar://problem/56784375
1 parent e716300 commit ee8447e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

stdlib/public/Reflection/TypeRefBuilder.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,18 @@ TypeRefBuilder::getBuiltinTypeInfo(const TypeRef *TR) {
253253

254254
for (auto Info : ReflectionInfos) {
255255
for (auto BuiltinTypeDescriptor : Info.Builtin) {
256-
if (BuiltinTypeDescriptor->getAlignment() <= 0)
257-
continue;
258256
if (BuiltinTypeDescriptor->Stride <= 0)
259257
continue;
260258
if (!BuiltinTypeDescriptor->hasMangledTypeName())
261259
continue;
260+
261+
auto Alignment = BuiltinTypeDescriptor->getAlignment();
262+
if (Alignment <= 0)
263+
continue;
264+
// Reject any alignment that's not a power of two.
265+
if (Alignment & (Alignment - 1))
266+
continue;
267+
262268
auto CandidateMangledName =
263269
readTypeRef(BuiltinTypeDescriptor, BuiltinTypeDescriptor->TypeName);
264270
if (!reflectionNameMatches(CandidateMangledName, MangledName))

0 commit comments

Comments
 (0)