Fix buffer is not sliced when read position > 0 and bytes remaining are less than bytes expected

fork
Chotiwat Chawannakul 12 years ago
parent 870899f664
commit 779cc7a33f

@ -160,16 +160,16 @@ ImapConnection.prototype.connect = function(loginCb) {
});
function read(b) {
var blen = b.length;
var blen = b.length, origPos = b.p;
if (ondata.expect <= (blen - b.p)) {
var left = ondata.expect, origPos = b.p;
var left = ondata.expect;
ondata.expect = 0;
b.p += left;
return b.slice(origPos, origPos + left);
} else {
ondata.expect -= (blen - b.p);
b.p = blen;
return b;
return origPos > 0 ? b.slice(origPos) : b;
}
}

Loading…
Cancel
Save