aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/preamble.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 1c66797b..d2bbc6a4 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -544,6 +544,9 @@ function Pointer_stringify(ptr, /* optional */ length) {
var i = 0;
var t;
while (1) {
+#if ASSERTIONS
+ assert(i < TOTAL_MEMORY);
+#endif
t = {{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}};
if (nullTerminated && t == 0) break;
ret += utf8.processCChar(t);
@@ -750,7 +753,11 @@ function exitRuntime() {
function String_len(ptr) {
var i = ptr;
- while ({{{ makeGetValue('i++', '0', 'i8') }}}) {}; // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
+ while ({{{ makeGetValue('i++', '0', 'i8') }}}) { // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
+#if ASSERTIONS
+ assert(i < TOTAL_MEMORY);
+#endif
+ }
return i - ptr - 1;
}
Module['String_len'] = String_len;