emmenlau commented on a change in pull request #2007:
URL: https://github.com/apache/thrift/pull/2007#discussion_r443385854



##########
File path: lib/cpp/src/thrift/transport/TBufferTransports.h
##########
@@ -587,11 +587,9 @@ class TMemoryBuffer : public 
TVirtualTransport<TMemoryBuffer, TBufferBase> {
   void resetBuffer() {
     rBase_ = buffer_;
     rBound_ = buffer_;
-    wBase_ = buffer_;
-    // It isn't safe to write into a buffer we don't own.
-    if (!owner_) {
-      wBound_ = wBase_;
-      bufferSize_ = 0;
+    if (owner_) {
+      wBase_ = buffer_;
+      wBound_ = buffer_ + bufferSize_;

Review comment:
       Could you explain this change a bit? Originally the code always set 
`wBase_ = buffer_;` but after your change, `wBase_` is only set if the buffer 
is owned. Is that guaranteed correct?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to