Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #305 from bmcustodio/fixes-304
Browse files Browse the repository at this point in the history
Make sure 'nextId' always fits in a uint8. (#304)
  • Loading branch information
mcollina committed Jul 17, 2015
2 parents 1315d4c + 0be6860 commit 4bc2682
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Client(conn, server) {
this.logger = server.logger;
this.subscriptions = {};

this.nextId = 1;
this.nextId = 0;
this.inflight = {};
this.inflightCounter = 0;
this._lastDedupId = -1;
Expand Down Expand Up @@ -214,6 +214,9 @@ Client.prototype._buildForward = function() {
forward = true,
newId = this.nextId++;

// Make sure 'nextId' always fits in a uint8 (http://git.io/vmgKI).
this.nextId %= 65536;

var packet = {
topic: topic,
payload: payload,
Expand Down

0 comments on commit 4bc2682

Please sign in to comment.