mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[RemoteMirror] Add NULL checks to Remote Mirror malloc calls.
These calls can fail when passed absurd sizes, which can happen when we try to read data that's corrupt or doesn't contain what we think it should. Fail gracefully instead of crashing. rdar://78210820
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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user