1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

Isolate::execute_mod wrap filename in CString (#1479)

When we called js_filename.as_ptr() without using CString it wasn't
necessarally null terminated, which was creating spurious failures.
This commit is contained in:
Ryan Dahl 2019-01-08 14:42:53 -05:00 committed by GitHub
parent 2558d6e184
commit 9ff6bca863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,7 +235,9 @@ impl Isolate {
let out = self.state.dir.code_fetch(js_filename, ".").unwrap();
debug!("module_resolve complete {}", out.filename);
// TODO js_source is not null terminated, therefore the clone.
let filename = CString::new(js_filename).unwrap();
let filename_ptr = filename.as_ptr() as *const i8;
let js_source = CString::new(out.js_source().clone()).unwrap();
let js_source_ptr = js_source.as_ptr() as *const i8;
@ -243,7 +245,7 @@ impl Isolate {
libdeno::deno_execute_mod(
self.libdeno_isolate,
self.as_raw_ptr(),
js_filename.as_ptr() as *const i8,
filename_ptr,
js_source_ptr,
)
};