Skip to content

Commit

Permalink
CBL-6378: Crash when calling onWebSocketGotTLSCertificate callback af…
Browse files Browse the repository at this point in the history
…ter the connection is closed

Have to synchronize _closed with onWebSocketGotTLSCertificate.
  • Loading branch information
jianminzhao committed Oct 29, 2024
1 parent a34d197 commit 6b9ff43
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Networking/BLIP/BLIPConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ namespace litecore::blip {
enqueue(FUNCTION_TO_QUEUE(BLIPIO::_gotHTTPResponse), status, headers);
}

void onWebSocketGotTLSCertificate(slice certData) override { _connection->gotTLSCertificate(certData); }
virtual void onWebSocketGotTLSCertificate(slice certData) override {
enqueue(FUNCTION_TO_QUEUE(BLIPIO::_gotTLSCertificate), alloc_slice{certData});
}

// websocket::Delegate interface:
void onWebSocketConnect() override {
Expand Down Expand Up @@ -210,6 +212,11 @@ namespace litecore::blip {
if ( _connection ) _connection->gotHTTPResponse(status, headers);
}

void _gotTLSCertificate(alloc_slice certData) {
// _connection is reset to nullptr in _closed.
if ( _connection ) _connection->gotTLSCertificate(certData);
}

void _onWebSocketConnect() {
// _connection is reset to nullptr in _closed.
if ( _connection ) {
Expand Down

0 comments on commit 6b9ff43

Please sign in to comment.