You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by he...@apache.org on 2012/09/24 21:11:19 UTC

svn commit: r1389517 - /thrift/trunk/lib/nodejs/lib/thrift/transport.js

Author: henrique
Date: Mon Sep 24 19:11:19 2012
New Revision: 1389517

URL: http://svn.apache.org/viewvc?rev=1389517&view=rev
Log:
Thrift-1701:node.js TBufferedTransport buffer corruption
Patch: Marshall Roch

fix buffer copy method calls

Modified:
    thrift/trunk/lib/nodejs/lib/thrift/transport.js

Modified: thrift/trunk/lib/nodejs/lib/thrift/transport.js
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/nodejs/lib/thrift/transport.js?rev=1389517&r1=1389516&r2=1389517&view=diff
==============================================================================
--- thrift/trunk/lib/nodejs/lib/thrift/transport.js (original)
+++ thrift/trunk/lib/nodejs/lib/thrift/transport.js Mon Sep 24 19:11:19 2012
@@ -165,7 +165,7 @@ TBufferedTransport.prototype = {
     var bufSize = (unreadedSize * 2 > this.defaultReadBufferSize) ? unreadedSize * 2 : this.defaultReadBufferSize;
     var buf = new Buffer(bufSize);
     if (unreadedSize > 0) {
-      this.inBuf.copy(buf, 0, this.readCursor, unreadedSize);
+      this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor);
     }
     this.readCursor = 0;
     this.writeCursor = unreadedSize;
@@ -195,7 +195,7 @@ TBufferedTransport.prototype = {
       throw new InputBufferUnderrunError();
     }
     var buf = new Buffer(this.writeCursor - this.readCursor);
-    this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor - this.readCursor);
+    this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor);
     this.readCursor = this.writeCursor;
     return buf;
   },