mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #37505 from mikeash/remotemirror-malloc-null-checks
[RemoteMirror] Add NULL checks to Remote Mirror malloc calls.
This commit is contained in:
@@ -100,6 +100,8 @@ public:
|
||||
virtual ReadBytesResult
|
||||
readBytes(RemoteAddress address, uint64_t size) {
|
||||
auto *Buf = malloc(size);
|
||||
if (!Buf)
|
||||
return ReadBytesResult{};
|
||||
ReadBytesResult Result(Buf, [](const void *ptr) {
|
||||
free(const_cast<void *>(ptr));
|
||||
});
|
||||
|
||||
@@ -1802,6 +1802,9 @@ private:
|
||||
MetadataRef _readMetadata(StoredPointer address, size_t sizeAfter) {
|
||||
auto size = sizeAfter;
|
||||
uint8_t *buffer = (uint8_t *) malloc(size);
|
||||
if (!buffer)
|
||||
return nullptr;
|
||||
|
||||
if (!Reader->readBytes(RemoteAddress(address), buffer, size)) {
|
||||
free(buffer);
|
||||
return nullptr;
|
||||
@@ -2522,6 +2525,8 @@ private:
|
||||
std::string readObjCProtocolName(StoredPointer Address) {
|
||||
auto Size = sizeof(TargetObjCProtocolPrefix<Runtime>);
|
||||
auto Buffer = (uint8_t *)malloc(Size);
|
||||
if (!Buffer)
|
||||
return std::string();
|
||||
SWIFT_DEFER {
|
||||
free(Buffer);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user