Be sure to only pop unsupported packet if already pushed

This commit is contained in:
Tankred Hase 2016-06-08 11:30:53 +02:00
parent fb10fa075a
commit e3cbaba33a

View File

@ -36,13 +36,17 @@ Packetlist.prototype.read = function (bytes) {
var parsed = packetParser.read(bytes, i, bytes.length - i);
i = parsed.offset;
var pushed = false;
try {
var tag = enums.read(enums.packet, parsed.tag);
var packet = packets.newPacketFromTag(tag);
this.push(packet);
pushed = true;
packet.read(parsed.packet);
} catch(e) {
this.pop(); // drop unsupported packet
if (pushed) {
this.pop(); // drop unsupported packet
}
}
}
};