Skip to content

Commit 3fbaf8b

Browse files
fixup! try to allocate arrays before borrow
1 parent 8616293 commit 3fbaf8b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ext/src/ruby_api/wasi_config.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,19 @@ impl WasiConfig {
255255
dir_perms: Symbol,
256256
file_perms: Symbol,
257257
) -> RbSelf {
258-
let mut inner = rb_self.inner.borrow_mut();
259-
if inner.mapped_directories.is_none() {
260-
inner.mapped_directories = Some(RArray::new().into());
261-
}
262258
let mapped_directory = RArray::new();
263259
mapped_directory.push(host_path).unwrap();
264260
mapped_directory.push(guest_path).unwrap();
265261
mapped_directory.push(dir_perms).unwrap();
266262
mapped_directory.push(file_perms).unwrap();
267263

264+
let init_directory = RArray::new();
265+
266+
let mut inner = rb_self.inner.borrow_mut();
267+
if inner.mapped_directories.is_none() {
268+
inner.mapped_directories = Some(init_directory.into());
269+
}
270+
268271
let ruby = Ruby::get().unwrap();
269272
let mapped_directories = ruby.get_inner(inner.mapped_directories.unwrap());
270273
mapped_directories.push(mapped_directory).unwrap();

0 commit comments

Comments
 (0)