Skip to content

Commit

Permalink
Isolate::execute_mod wrap filename in CString (denoland#1479)
Browse files Browse the repository at this point in the history
When we called js_filename.as_ptr() without using CString it wasn't
necessarally null terminated, which was creating spurious failures.
  • Loading branch information
ry authored Jan 8, 2019
1 parent 2558d6e commit 9ff6bca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,17 @@ 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;

let r = unsafe {
libdeno::deno_execute_mod(
self.libdeno_isolate,
self.as_raw_ptr(),
js_filename.as_ptr() as *const i8,
filename_ptr,
js_source_ptr,
)
};
Expand Down

0 comments on commit 9ff6bca

Please sign in to comment.