Skip to content

Commit

Permalink
Fixed bug with calls to ensureSpaceFor() not considering offset
Browse files Browse the repository at this point in the history
  • Loading branch information
tautologistics committed May 13, 2010
1 parent 4e2e6eb commit 262e138
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/redis-client.js
Expand Up @@ -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);
}
}
Expand Down

1 comment on commit 262e138

@fictorial
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.