From: Woo Xie Date: Tue, 30 Jun 2015 16:21:08 +0000 (-0700) Subject: check ReadCallback before using it X-Git-Tag: v0.49.0~21 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a09c094f1a0c8de5c9379dd1931b80c6b057c101;p=folly.git 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 --- diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 9c59cce7..e3df3950 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -1073,7 +1073,7 @@ AsyncSSLSocket::handleConnect() noexcept { void AsyncSSLSocket::setReadCB(ReadCallback *callback) { #ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP // 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); isBufferMovable_ = true; } diff --git a/folly/io/async/AsyncSSLSocket.h b/folly/io/async/AsyncSSLSocket.h index 2cae50a4..fe72e8f9 100644 --- a/folly/io/async/AsyncSSLSocket.h +++ b/folly/io/async/AsyncSSLSocket.h @@ -656,6 +656,8 @@ class AsyncSSLSocket : public virtual AsyncSocket { return minWriteSize_; } + void setReadCB(ReadCallback* callback) override; + private: void init(); @@ -673,7 +675,6 @@ class AsyncSSLSocket : public virtual AsyncSocket { // Inherit event notification methods from AsyncSocket except // the following. - void setReadCB(ReadCallback* callback) override; void prepareReadBuffer(void** buf, size_t* buflen) noexcept override; void handleRead() noexcept override; void handleWrite() noexcept override;