Commit a09c094f authored by Woo Xie's avatar Woo Xie Committed by Sara Golemon

check ReadCallback before using it

Summary: before the first setReadCallback(), the readCallback_ is nullptr.  Thanks @siyengar for pointing out this!

Reviewed By: @siyengar

Differential Revision: D2203489
parent a93384bd
...@@ -1073,7 +1073,7 @@ AsyncSSLSocket::handleConnect() noexcept { ...@@ -1073,7 +1073,7 @@ AsyncSSLSocket::handleConnect() noexcept {
void AsyncSSLSocket::setReadCB(ReadCallback *callback) { void AsyncSSLSocket::setReadCB(ReadCallback *callback) {
#ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP #ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP
// turn on the buffer movable in openssl // turn on the buffer movable in openssl
if (!isBufferMovable_ && readCallback_->isBufferMovable()) { if (!isBufferMovable_ && callback != nullptr && callback->isBufferMovable()) {
SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP); SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP);
isBufferMovable_ = true; isBufferMovable_ = true;
} }
......
...@@ -656,6 +656,8 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -656,6 +656,8 @@ class AsyncSSLSocket : public virtual AsyncSocket {
return minWriteSize_; return minWriteSize_;
} }
void setReadCB(ReadCallback* callback) override;
private: private:
void init(); void init();
...@@ -673,7 +675,6 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -673,7 +675,6 @@ class AsyncSSLSocket : public virtual AsyncSocket {
// Inherit event notification methods from AsyncSocket except // Inherit event notification methods from AsyncSocket except
// the following. // the following.
void setReadCB(ReadCallback* callback) override;
void prepareReadBuffer(void** buf, size_t* buflen) noexcept override; void prepareReadBuffer(void** buf, size_t* buflen) noexcept override;
void handleRead() noexcept override; void handleRead() noexcept override;
void handleWrite() noexcept override; void handleWrite() noexcept override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment