summaryrefslogtreecommitdiff
path: root/src/passes/SafeHeap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/SafeHeap.cpp')
-rw-r--r--src/passes/SafeHeap.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp
index 61db334a0..b095b741d 100644
--- a/src/passes/SafeHeap.cpp
+++ b/src/passes/SafeHeap.cpp
@@ -218,7 +218,7 @@ struct SafeHeap : public Pass {
);
// check for reading past valid memory: if pointer + offset + bytes
block->list.push_back(
- makeBoundsCheck(style.type, builder, 2)
+ makeBoundsCheck(style.type, builder, 2, style.bytes)
);
// check proper alignment
if (style.align > 1) {
@@ -265,7 +265,7 @@ struct SafeHeap : public Pass {
);
// check for reading past valid memory: if pointer + offset + bytes
block->list.push_back(
- makeBoundsCheck(style.valueType, builder, 3)
+ makeBoundsCheck(style.valueType, builder, 3, style.bytes)
);
// check proper alignment
if (style.align > 1) {
@@ -295,7 +295,7 @@ struct SafeHeap : public Pass {
);
}
- Expression* makeBoundsCheck(Type type, Builder& builder, Index local) {
+ Expression* makeBoundsCheck(Type type, Builder& builder, Index local, Index bytes) {
return builder.makeIf(
builder.makeBinary(
OrInt32,
@@ -309,7 +309,7 @@ struct SafeHeap : public Pass {
builder.makeBinary(
AddInt32,
builder.makeGetLocal(local, i32),
- builder.makeConst(Literal(int32_t(getTypeSize(type))))
+ builder.makeConst(Literal(int32_t(bytes)))
),
builder.makeLoad(4, false, 0, 4,
builder.makeGetGlobal(dynamicTopPtr, i32), i32