Skip to content

Commit 4e26d84

Browse files
committed
fix a use-after free in MemoryLocations
rdar://75441030
1 parent d608cb5 commit 4e26d84

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/SIL/Utils/MemoryLocations.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,12 @@ bool MemoryLocations::analyzeAddrProjection(
396396
if (isEmptyType(projection->getType(), projection->getFunction()))
397397
return false;
398398

399-
unsigned &subLocIdx = subLocationMap[std::make_pair(parentLocIdx, fieldNr)];
399+
auto key = std::make_pair(parentLocIdx, fieldNr);
400+
unsigned subLocIdx = subLocationMap[key];
400401
if (subLocIdx == 0) {
401402
subLocIdx = locations.size();
402403
assert(subLocIdx > 0);
404+
subLocationMap[key] = subLocIdx;
403405
locations.push_back(Location(projection, subLocIdx, parentLocIdx));
404406

405407
Location &parentLoc = locations[parentLocIdx];

0 commit comments

Comments
 (0)