Skip to content

Commit 142b4f4

Browse files
committed
Don't crash if malloc fails
Resolves rdar://61159451
1 parent 21c161d commit 142b4f4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,9 @@ class MetadataReader {
10881088

10891089
unsigned size = baseSize + genericsSize + metadataInitSize + vtableSize;
10901090
auto buffer = (uint8_t *)malloc(size);
1091+
if (buffer == nullptr) {
1092+
return nullptr;
1093+
}
10911094
if (!Reader->readBytes(RemoteAddress(address), buffer, size)) {
10921095
free(buffer);
10931096
return nullptr;

0 commit comments

Comments
 (0)