diff options
author | ngld <ngld@tproxy.de> | 2013-09-17 21:12:02 +0200 |
---|---|---|
committer | ngld <ngld@tproxy.de> | 2013-09-17 21:12:02 +0200 |
commit | 21efbaf73322c17a62ef28ea0df21515c67c5e2a (patch) | |
tree | d2d360a5970ce019d0c41476af0a438cd893b086 /src/preamble.js | |
parent | 147bc5e8b13ee6659b6a259a29400c53c537fb1c (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.js | 9 |
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); |