Skip to content

Commit

Permalink
Fix potential null error in JsValue::as_debug_string() (#4192)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Oct 14, 2024
1 parent ae1d105 commit d6406e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* Fixed `#[should_panic]` not working with `#[wasm_bindgen_test(unsupported = ...)]`.
[#4196](https://github.com/rustwasm/wasm-bindgen/pull/4196)

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

--------------------------------------------------------------------------------

## [0.2.95](https://github.com/rustwasm/wasm-bindgen/compare/0.2.94...0.2.95)
Expand Down
3 changes: 1 addition & 2 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,6 @@ __wbg_set_wasm(wasm);"
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
return instance.ptr;
}
",
);
Expand Down Expand Up @@ -3986,7 +3985,7 @@ __wbg_set_wasm(wasm);"
// Test for built-in
const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));
let className;
if (builtInMatches.length > 1) {
if (builtInMatches && builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/reference/web-sys.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function debugString(val) {
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches.length > 1) {
if (builtInMatches && builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
Expand Down

0 comments on commit d6406e1

Please sign in to comment.