Skip to content

Commit 6a625d6

Browse files
authored
compiler: Don't read abnormally large arrays (#112)
Avoid OOM crashes when parsing arrays with abnormally large sizes
1 parent ecef4d3 commit 6a625d6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/datatypes/compiler-structures.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
} else {
1111
throw new Error('Array must contain either count or countType')
1212
}
13+
code += 'if (count > 0xffffff) throw new Error("array size is abnormally large, not reading: " + count)\n'
1314
code += 'const data = []\n'
1415
code += 'let size = countSize\n'
1516
code += 'for (let i = 0; i < count; i++) {\n'

0 commit comments

Comments
 (0)