aboutsummaryrefslogtreecommitdiff
path: root/src/corruptionCheck.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-17 17:56:48 +0100
committerAlon Zakai <alonzakai@gmail.com>2013-02-17 17:56:48 +0100
commit5c89eb1d5abd30e7ac5c8d88ab1d828f4ec4883d (patch)
treefd9b154fac2e05267c934118def2d9acaf6003b5 /src/corruptionCheck.js
parentb3e9426b9775daf99210f337659a37876013d623 (diff)
print out # of corruption checks on exit
Diffstat (limited to 'src/corruptionCheck.js')
-rw-r--r--src/corruptionCheck.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corruptionCheck.js b/src/corruptionCheck.js
index 0616337b..ce670401 100644
--- a/src/corruptionCheck.js
+++ b/src/corruptionCheck.js
@@ -5,6 +5,7 @@ var CorruptionChecker = {
BUFFER_FACTOR: {{{ CORRUPTION_CHECK }}},
ptrs: {},
+ checks: 0,
init: function() {
this.realMalloc = _malloc;
@@ -12,6 +13,10 @@ var CorruptionChecker = {
this.realFree = _free;
_free = Module['_free'] = this.free;
+
+ __ATEXIT__.push({ func: function() {
+ Module.printErr('No corruption detected, ran ' + CorruptionChecker.checks + ' checks.');
+ } });
},
malloc: function(size) {
assert(size > 0); // some mallocs accept zero - fix your code if you want to use this tool
@@ -38,6 +43,7 @@ var CorruptionChecker = {
for (var x = allocation; x < allocation + size; x++) {
assert(({{{ makeGetValue('x', 0, 'i8') }}}&255) == CorruptionChecker.canary(x), 'Heap corruption detected!');
}
+ CorruptionChecker.checks++;
},
checkPtr: function(ptr, free) {
var size = CorruptionChecker.ptrs[ptr];