aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-28 18:36:46 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:19 -0800
commitedfa19745e86763db4574ccb9fc73f5ecfaadecb (patch)
tree89d6fdffc1a455135bb70cf1a5ebb0f334c6de25 /src/parseTools.js
parent816af5b04c7374df3022ed2d863df9b74638258d (diff)
guard against heap read values in asm.js
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 2bc2b407..9e0d4f9f 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1003,7 +1003,15 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
if (type[0] === '#') type = type.substr(1);
return 'SAFE_HEAP_LOAD(' + offset + ', ' + type + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')';
} else {
- return makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type) + ']';
+ var ret = makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type) + ']';
+ if (ASM_JS) {
+ if (type in Runtime.INT_TYPES) {
+ ret = ret + '|0';
+ } else {
+ ret = '+' + ret;
+ }
+ }
+ return ret;
}
}