mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-22 15:11:04 -05:00
fix: url
param to v8::WasmStreaming::SetUrl()
must be null terminated (#854)
This commit is contained in:
parent
b6a16916ce
commit
251f1e9ac9
1 changed files with 4 additions and 1 deletions
|
@ -61,10 +61,13 @@ impl WasmStreaming {
|
|||
/// Sets the UTF-8 encoded source URL for the `Script` object. This must be
|
||||
/// called before [`Self::finish()`].
|
||||
pub fn set_url(&mut self, url: &str) {
|
||||
// Although not documented, V8 requires the url to be null terminated.
|
||||
// See https://chromium-review.googlesource.com/c/v8/v8/+/3289148.
|
||||
let null_terminated_url = format!("{}\0", url);
|
||||
unsafe {
|
||||
v8__WasmStreaming__SetUrl(
|
||||
&mut self.0,
|
||||
url.as_ptr() as *const char,
|
||||
null_terminated_url.as_ptr() as *const char,
|
||||
url.len(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue