aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-08-29 13:39:54 -0700
committerBruce Mitchener <bruce.mitchener@gmail.com>2014-02-04 16:16:10 +0700
commit1511e68f617e555b5342fe9df693eed07ffac8cb (patch)
tree5c3611d9e2da0530e42b5f79edcd2b2caf21531c /src
parent04b624f10d7f040e5e9551e9c956c4b0ca7c66b0 (diff)
Fix a possible memory corruption bug when using val::as
Diffstat (limited to 'src')
-rw-r--r--src/embind/emval.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/embind/emval.js b/src/embind/emval.js
index 0d075188..d4e4271d 100644
--- a/src/embind/emval.js
+++ b/src/embind/emval.js
@@ -3,7 +3,7 @@
/*global new_*/
/*global createNamedFunction*/
/*global readLatin1String, writeStringToMemory*/
-/*global requireRegisteredType, throwBindingError*/
+/*global requireRegisteredType, throwBindingError, runDestructors*/
/*jslint sub:true*/ /* The symbols 'fromWireType' and 'toWireType' must be accessed via array notation to be closure-safe since craftInvokerFunction crafts functions as strings that can't be closured. */
var Module = Module || {};
@@ -199,11 +199,12 @@ function __emval_set_property(handle, key, value) {
_emval_handle_array[handle].value[_emval_handle_array[key].value] = _emval_handle_array[value].value;
}
-function __emval_as(handle, returnType) {
+function __emval_as(handle, returnType, runDestructorsRef) {
requireHandle(handle);
returnType = requireRegisteredType(returnType, 'emval::as');
var destructors = [];
- // caller owns destructing
+ var rd = __emval_register(runDestructors.bind(undefined, destructors));
+ HEAP32[runDestructorsRef >> 2] = rd;
return returnType['toWireType'](destructors, _emval_handle_array[handle].value);
}