aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/embind/embind.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index f66b0495..f9b15fa3 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -336,7 +336,12 @@ function __embind_register_std_string(rawType, name) {
var ptr = _malloc(4 + length);
HEAPU32[ptr >> 2] = length;
for (var i = 0; i < length; ++i) {
- HEAPU8[ptr + 4 + i] = value.charCodeAt(i);
+ var charCode = value.charCodeAt(i);
+ if (charCode > 255) {
+ _free(ptr);
+ throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
+ }
+ HEAPU8[ptr + 4 + i] = charCode;
}
destructors.push(_free, ptr);
return ptr;