Skip to content

Commit

Permalink
Merge pull request #228 from jucapablanca/master
Browse files Browse the repository at this point in the history
Corrections for reading empty blobs and varchar charset none
  • Loading branch information
mariuz authored Sep 2, 2020
2 parents 43231fd + 3f4eb12 commit 18a2aeb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ BlrReader.prototype.readSegment = function() {
this.pos += 2;
}

return ret;
return ret ? ret : Buffer.alloc(0);
};

/***************************************
Expand Down Expand Up @@ -401,16 +401,21 @@ XdrReader.prototype.readArray = function () {
return r;
};

XdrReader.prototype.readBuffer = function(len, toAlign = true) {
if (!arguments.length)
len = this.readInt();
XdrReader.prototype.readBuffer = function (len, toAlign = true) {
if (!arguments.length) {
len = this.readInt();
}

if (!len)
return;
if (len !== null && len !== undefined) {

var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += toAlign ? align(len) : len;
return r;
if (len <= 0){
return Buffer.alloc(0);
}

var r = this.buffer.slice(this.pos, this.pos + len);
this.pos += toAlign ? align(len) : len;
return r;
}
};

XdrReader.prototype.readString = function(encoding) {
Expand Down

0 comments on commit 18a2aeb

Please sign in to comment.