commit 0db8401a456f08d755af57f7bfde6d7b255faf1e parent f7b2ae93b9e7ce06a82f296696976d0fb458f869 Author: Andy Herbert <andy.herbert@gmail.com> Date: Sun, 3 Nov 2013 19:33:31 +0000 Sanity check the fileSize metadata in a sauce record before using it. Diffstat:
M | ansilove.js | | | 10 | +++++++++- |
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ansilove.js b/ansilove.js @@ -112,7 +112,15 @@ var AnsiLove = (function () { } pos = 0; - this.size = this.sauce ? this.sauce.fileSize : bytes.length; + if (this.sauce) { + if (this.sauce.fileSize > 0 && this.sauce.fileSize < bytes.length) { + this.size = this.sauce.fileSize; + } else { + this.size = bytes.length - 128; + } + } else { + this.size = bytes.length; + } } function createCanvas(width, height) {