Fix AudioBuffer crash. Do not modify number of channels while moving from shared to js channels

This commit is contained in:
Fernando Jiménez Moreno 2018-09-04 15:23:11 +02:00
parent 3889041cc6
commit e80ac0000f

View file

@ -134,8 +134,8 @@ impl AudioBuffer {
// Move the channel data from shared_channels to js_channels.
rooted!(in (cx) let mut array = ptr::null_mut::<JSObject>());
let shared_channel = (*self.shared_channels.borrow_mut()).buffers.remove(i);
if Float32Array::create(cx, CreateWith::Slice(&shared_channel), array.handle_mut())
let shared_channel = &(*self.shared_channels.borrow_mut()).buffers[i];
if Float32Array::create(cx, CreateWith::Slice(shared_channel), array.handle_mut())
.is_err()
{
return false;
@ -182,8 +182,6 @@ impl AudioBuffer {
// data into js_channels ArrayBuffers in restore_js_channel_data.
}
self.js_channels.borrow_mut().clear();
Some((*self.shared_channels.borrow()).clone())
}
}