jsstring_to_str should accept a NonNull argument for the JS string (#33306)

Instead of asserting the raw pointer is not null, force callers to
produce a NonNull pointer.

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
This commit is contained in:
Andriy Sultanov 2024-09-05 04:25:49 +01:00 committed by GitHub
parent 642c25d9a7
commit aadc212b95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 38 deletions

View file

@ -71,13 +71,14 @@ pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<E
},
)
} else if rval.is_string() {
EvaluateJSReply::StringValue(String::from(jsstring_to_str(*cx, rval.to_string())))
let jsstr = std::ptr::NonNull::new(rval.to_string()).unwrap();
EvaluateJSReply::StringValue(String::from(jsstring_to_str(*cx, jsstr)))
} else if rval.is_null() {
EvaluateJSReply::NullValue
} else {
assert!(rval.is_object());
let jsstr = ToString(*cx, rval.handle());
let jsstr = std::ptr::NonNull::new(ToString(*cx, rval.handle())).unwrap();
let class_name = jsstring_to_str(*cx, jsstr);
EvaluateJSReply::ActorValue {