diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-06-25 23:31:10 +0200 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-06-26 12:36:56 +0200 |
commit | 4ae96c885bd3118a1f19972b90aabbc83cf5b20b (patch) | |
tree | 906ac806766750f7d83dbf886525fc7f76335e86 /src/node_crypto_bio.cc | |
parent | adf9b67e591fe1df9589412a75bad357a9410aa3 (diff) | |
download | node-new-4ae96c885bd3118a1f19972b90aabbc83cf5b20b.tar.gz |
crypto: do not move half-filled write head
Might cause write head running over read head, when there were no
allocation and `Commit()` was called. Source of at least one test
failure on windows (`simple/test-https-drain.js`).
Diffstat (limited to 'src/node_crypto_bio.cc')
-rw-r--r-- | src/node_crypto_bio.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index 9afaa3d353..2932f64bf2 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -315,6 +315,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) { + assert(write_head_->write_pos_ == kBufferLength); TryAllocateForWrite(); write_head_ = write_head_->next_; } @@ -342,7 +343,8 @@ void NodeBIO::Commit(size_t size) { // Allocate new buffer if write head is full, // and there're no other place to go TryAllocateForWrite(); - write_head_ = write_head_->next_; + if (write_head_->write_pos_ == kBufferLength) + write_head_ = write_head_->next_; } |