Merge pull request #1 from zacharee/fix-stackoverflow

Avoid a StackOverflow when re-emitting packets
This commit is contained in:
Ari Sosnovsky authored and GitHub committed 2025-01-01 13:58:39 -05:00
commit df74989fdd
1 file changed
+7
+7
View File
@@ -928,6 +928,13 @@ MQTT.prototype.packetHandler = function(data) {
}
// Get the data for this packet
var pData = data.slice(1 + dLen.lenBy, pLen);
// Avoid an infinite data emit loop
if (pData.length < 1) {
this.partData = data;
return;
}
// more than one packet? re-emit it so we handle it later
if (data.length > pLen) {
this.client.emit("data", data.slice(pLen, data.length));