Skip to content

Commit d6406e1

Browse files
Fix potential null error in JsValue::as_debug_string() (rustwasm#4192)
1 parent ae1d105 commit d6406e1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* Fixed `#[should_panic]` not working with `#[wasm_bindgen_test(unsupported = ...)]`.
2626
[#4196](https://github.com/rustwasm/wasm-bindgen/pull/4196)
2727

28+
* Fixed potential `null` error when using `JsValue::as_debug_string()`.
29+
[#4192](https://github.com/rustwasm/wasm-bindgen/pull/4192)
30+
2831
--------------------------------------------------------------------------------
2932

3033
## [0.2.95](https://github.com/rustwasm/wasm-bindgen/compare/0.2.94...0.2.95)

crates/cli-support/src/js/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,6 @@ __wbg_set_wasm(wasm);"
19581958
if (!(instance instanceof klass)) {
19591959
throw new Error(`expected instance of ${klass.name}`);
19601960
}
1961-
return instance.ptr;
19621961
}
19631962
",
19641963
);
@@ -3986,7 +3985,7 @@ __wbg_set_wasm(wasm);"
39863985
// Test for built-in
39873986
const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));
39883987
let className;
3989-
if (builtInMatches.length > 1) {
3988+
if (builtInMatches && builtInMatches.length > 1) {
39903989
className = builtInMatches[1];
39913990
} else {
39923991
// Failed to match the standard '[object ClassName]'

crates/cli/tests/reference/web-sys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function debugString(val) {
9090
// Test for built-in
9191
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
9292
let className;
93-
if (builtInMatches.length > 1) {
93+
if (builtInMatches && builtInMatches.length > 1) {
9494
className = builtInMatches[1];
9595
} else {
9696
// Failed to match the standard '[object ClassName]'

0 commit comments

Comments
 (0)