Skip to content

Commit 5c64253

Browse files
ironagejedelbo
authored andcommitted
fix accidental use after free
1 parent bc25579 commit 5c64253

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/realm/sync/network/network_ssl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,16 @@ std::string SecureTransportErrorCategory::message(int value) const
206206
{
207207
const char* message = "Unknown error";
208208
#if REALM_HAVE_SECURE_TRANSPORT
209+
std::unique_ptr<char[]> buffer;
209210
if (__builtin_available(iOS 11.3, macOS 10.3, tvOS 11.3, watchOS 4.3, *)) {
210211
auto status = OSStatus(value);
211212
void* reserved = nullptr;
212-
std::unique_ptr<char[]> buffer;
213213
if (auto cf_message = adoptCF(SecCopyErrorMessageString(status, reserved)))
214214
message = cfstring_to_cstring(cf_message.get(), buffer);
215215
}
216+
else {
217+
static_cast<void>(buffer);
218+
}
216219
#endif // REALM_HAVE_SECURE_TRANSPORT
217220

218221
return util::format("SecureTransport error: %1 (%2)", message, value); // Throws

0 commit comments

Comments
 (0)