Skip to content

Commit

Permalink
Fixed negative values in the lock-token generation
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 7, 2017
1 parent a745c95 commit 5ad148f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/resource/lock/Lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var Lock = (function () {
var rnd1 = Math.ceil(Math.random() * 0x3FFF) + 0x8000;
var rnd2 = Math.ceil(Math.random() * 0xFFFFFFFF);
function pad(value, nb) {
if (value < 0)
value *= -1;
var str = Math.ceil(value).toString(16);
while (str.length < nb)
str = '0' + str;
Expand Down
3 changes: 3 additions & 0 deletions src/resource/lock/Lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class Lock

function pad(value : number, nb : number)
{
if(value < 0)
value *= -1;

let str = Math.ceil(value).toString(16);
while(str.length < nb)
str = '0' + str;
Expand Down

0 comments on commit 5ad148f

Please sign in to comment.