You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2020/06/22 08:09:24 UTC

[GitHub] [thrift] emmenlau commented on a change in pull request #2007: THRIFT-5093: TMemoryBuffer fix wpos for policy == OBSERVER

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:
users@infra.apache.org