crypto: ensure that read head is always non-empty
authorFedor Indutny <fedor.indutny@gmail.com>
Tue, 11 Jun 2013 14:11:48 +0000 (16:11 +0200)
committerFedor Indutny <fedor.indutny@gmail.com>
Sat, 15 Jun 2013 19:43:24 +0000 (21:43 +0200)
src/node_crypto_bio.cc

index 9d566fd..547c711 100644 (file)
@@ -203,8 +203,10 @@ size_t NodeBIO::Read(char* out, size_t size) {
       read_head_->write_pos_ = 0;
 
       // But not get beyond write_head_
-      if (bytes_read != expected)
+      if (length_ != bytes_read) {
+        assert(read_head_ != write_head_);
         read_head_ = read_head_->next_;
+      }
     }
   }
   assert(expected == bytes_read);