From c3b9fdfc75141ff7d175070430c7c4e706cb72ca Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 6 Mar 2014 19:24:20 +0100 Subject: [PATCH] Fixed long messages bug --- app/js/lib/mtproto.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index e7829b95..0de0af51 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -378,9 +378,8 @@ TLSerialization.prototype.checkLength = function (needBytes) { return; } - console.log('Increase buffer', this.offset, needBytes, this.maxLength); - console.trace(); - this.maxLength = Math.max(this.maxLength * 2, this.offset + needBytes + 16); + console.trace('Increase buffer', this.offset, needBytes, this.maxLength); + this.maxLength = Math.ceil(Math.max(this.maxLength * 2, this.offset + needBytes + 16) / 4) * 4; var previousBuffer = this.buffer, previousArray = new Int32Array(previousBuffer);