Skip to content

Commit 4ae96c8

Browse files
committed
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`).
1 parent adf9b67 commit 4ae96c8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/node_crypto_bio.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ void NodeBIO::Write(const char* data, size_t size) {
315315

316316
// Go to next buffer if there still are some bytes to write
317317
if (left != 0) {
318+
assert(write_head_->write_pos_ == kBufferLength);
318319
TryAllocateForWrite();
319320
write_head_ = write_head_->next_;
320321
}
@@ -342,7 +343,8 @@ void NodeBIO::Commit(size_t size) {
342343
// Allocate new buffer if write head is full,
343344
// and there're no other place to go
344345
TryAllocateForWrite();
345-
write_head_ = write_head_->next_;
346+
if (write_head_->write_pos_ == kBufferLength)
347+
write_head_ = write_head_->next_;
346348
}
347349

348350

0 commit comments

Comments
 (0)