0
0
Fork 0
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:
Bert Belder 2021-12-12 20:12:24 -08:00
parent b6a16916ce
commit 251f1e9ac9
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -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(),
)
}