Permalink
Browse files

Fixed bug with calls to ensureSpaceFor() not considering offset

  • Loading branch information...
1 parent 4e2e6eb commit 262e13875071fa906f604706e940bd61edc2429a @tautologistics committed May 13, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/redis-client.js
View
@@ -708,14 +708,14 @@ Client.prototype.sendCommand = function () {
for (var i=1; i < argCount; ++i) {
var arg = arguments[i];
if (arg instanceof Buffer) {
- ensureSpaceFor(arg.length + arg.length.toString().length + extrasLength);
+ ensureSpaceFor(arg.length + arg.length.toString().length + extrasLength + offset);
offset += this.requestBuffer.asciiWrite('$' + arg.length + CRLF, offset);
offset += arg.copy(this.requestBuffer, offset, 0); // target, targetStart, srcStart
offset += this.requestBuffer.asciiWrite(CRLF, offset);
} else if (arg.toString) {
var asString = arg.toString();
var serialized = '$' + Buffer.byteLength(asString, "binary") + CRLF + asString + CRLF;
- ensureSpaceFor(Buffer.byteLength(serialized, "binary"));
+ ensureSpaceFor(Buffer.byteLength(serialized, "binary") + offset);
offset += this.requestBuffer.binaryWrite(serialized, offset);
}
}

1 comment on commit 262e138

ensureSpaceFor takes offset into account. Care to create a failing test case?

Please sign in to comment.