crypto: fix changing buffers in bio
authorFedor Indutny <fedor.indutny@gmail.com>
Sat, 6 Apr 2013 19:26:00 +0000 (23:26 +0400)
committerFedor Indutny <fedor.indutny@gmail.com>
Wed, 10 Apr 2013 12:55:10 +0000 (16:55 +0400)
We should go to next buffer if *current* one is full, not the next one.
Otherwise we may hop through buffers and written data will become
interleaved, which will lead to failure.

src/node_crypto_bio.cc

index d17ee21..d69eeb8 100644 (file)
@@ -279,7 +279,7 @@ void NodeBIO::Write(const char* data, size_t size) {
 
     // Go to next buffer if there still are some bytes to write
     if (left != 0) {
-      if (write_head_->next_->write_pos_ == kBufferLength) {
+      if (write_head_->write_pos_ == kBufferLength) {
         Buffer* next = new Buffer();
         next->next_ = write_head_->next_;
         write_head_->next_ = next;