aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorngld <ngld@tproxy.de>2013-09-17 21:12:02 +0200
committerngld <ngld@tproxy.de>2013-09-17 21:12:02 +0200
commit21efbaf73322c17a62ef28ea0df21515c67c5e2a (patch)
treed2d360a5970ce019d0c41476af0a438cd893b086 /src/preamble.js
parent147bc5e8b13ee6659b6a259a29400c53c537fb1c (diff)
Fix #1166: Correct the amount of allocated memory for non-ascii strings in ccallFunc().
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 02935f8f..eb522975 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -299,11 +299,10 @@ function ccallFunc(func, returnType, argTypes, args) {
function toC(value, type) {
if (type == 'string') {
if (value === null || value === undefined || value === 0) return 0; // null string
- if (!stack) stack = Runtime.stackSave();
- var ret = Runtime.stackAlloc(value.length+1);
- writeStringToMemory(value, ret);
- return ret;
- } else if (type == 'array') {
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length);
writeArrayToMemory(value, ret);