aboutsummaryrefslogtreecommitdiff
path: root/misc/wasm
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2018-06-29 23:09:34 -0400
committerCherry Zhang <cherryyz@google.com>2018-07-01 21:36:23 +0000
commit28f9b880f6e9f95c61b31b6e0a7ac458cb6a0e0c (patch)
tree19700f31520a82ef4f0e730a9bfe12193e0d449f /misc/wasm
parent6780042f0a30569abcc3c5e9e0376761ac928ef5 (diff)
downloadgo-28f9b880f6e9f95c61b31b6e0a7ac458cb6a0e0c.tar.gz
go-28f9b880f6e9f95c61b31b6e0a7ac458cb6a0e0c.zip
misc/wasm: make sure value ref id is unique
For each Javascript object that returns to Go as a js.Value, we associate the ref id to it. But if this ref id is copied or inherited to other object, it would mess up the ref-object mapping. In storeValue, make sure the object is indeed the one we are storing. Otherwise allocate a new ref id. Fixes #26143. Change-Id: Ie60bb2f8d1533da1bbe6f46045866515ec2af5a9 Reviewed-on: https://go-review.googlesource.com/121835 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Richard Musiol <neelance@gmail.com>
Diffstat (limited to 'misc/wasm')
-rw-r--r--misc/wasm/wasm_exec.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index ecb096509f..3617c49866 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -141,7 +141,7 @@
}
let ref = v[this._refProp];
- if (ref === undefined) {
+ if (ref === undefined || this._values[ref] !== v) {
ref = this._values.length;
this._values.push(v);
v[this._refProp] = ref;