Skip to content
Browse files

Handle empty strings correctly

  • Loading branch information...
1 parent 143f7d1 commit b0ff15f8d86da34c8331712496b90c1215d4f9ac @codeaholics committed Jul 15, 2013
View
0 bin/rdbdump 100644 → 100755
File mode changed.
View
13 lib/parser.js
@@ -140,7 +140,6 @@ function Parser(options) {
expiry: expiry,
offset: startOfRecord
};
-
switch(valueType) {
case 0:
object.rtype = 'string';
@@ -506,10 +505,14 @@ function Parser(options) {
function getBytes(cb) {
getLengthEncoding(function(n, special, output) {
if (!special) {
- bytes(n, function(buffer, output) {
- if (buffer.length != n) throw new Error('Incorrect read length');
- cb(buffer, output);
- });
+ if (n != 0) {
+ bytes(n, function(buffer, output) {
+ if (buffer.length != n) throw new Error('Incorrect read length');
+ cb(buffer, output);
+ });
+ } else {
+ cb(new Buffer(0), output);
+ }
} else {
switch (n) {
case 0:
View
BIN test/dumps/empty_string.rdb
Binary file not shown.
View
BIN test/dumps/error_reporting.rdb
Binary file not shown.

0 comments on commit b0ff15f

Please sign in to comment.
Something went wrong with that request. Please try again.