Skip to content

Commit f03e673

Browse files
lpincaDTrejo
authored andcommitted
Fix cases where the offset is out of range (javascript parser)
The exception for the "too far" error was not thrown if the offset was bigger than the buffer length, screwing up the parser. Fix #277 Signed-off-by: DTrejo <[email protected]>
1 parent 1dbe587 commit f03e673

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/parser/javascript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ ReplyParser.prototype._parseResult = function (type) {
125125
for (i = 0; i < packetHeader.size; i++) {
126126
ntype = this._buffer[this._offset++];
127127

128-
if (this._offset === this._buffer.length) {
128+
if (this._offset > this._buffer.length) {
129129
throw new Error("too far");
130130
}
131131
res = this._parseResult(ntype);
132132
if (res === undefined) {
133-
res = null;
133+
res = null;
134134
}
135135
reply.push(res);
136136
}

0 commit comments

Comments
 (0)