mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Make restore_js_channel_data unsafe
This commit is contained in:
parent
c5abc3eb8b
commit
3fc9ecace0
1 changed files with 4 additions and 6 deletions
|
@ -84,7 +84,7 @@ impl AudioBuffer {
|
||||||
reflect_dom_object(Box::new(buffer), global, AudioBufferBinding::Wrap)
|
reflect_dom_object(Box::new(buffer), global, AudioBufferBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-audiobuffer-audiobuffer
|
// https://webaudio.github.io/web-audio-api/#dom-audiobuffer-audiobuffer
|
||||||
pub fn Constructor(window: &Window,
|
pub fn Constructor(window: &Window,
|
||||||
options: &AudioBufferOptions) -> Fallible<DomRoot<AudioBuffer>> {
|
options: &AudioBufferOptions) -> Fallible<DomRoot<AudioBuffer>> {
|
||||||
if options.numberOfChannels > MAX_CHANNEL_COUNT {
|
if options.numberOfChannels > MAX_CHANNEL_COUNT {
|
||||||
|
@ -94,7 +94,7 @@ impl AudioBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn restore_js_channel_data(&self, cx: *mut JSContext) -> bool {
|
unsafe fn restore_js_channel_data(&self, cx: *mut JSContext) -> bool {
|
||||||
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
|
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
|
||||||
if !channel.get().is_null() {
|
if !channel.get().is_null() {
|
||||||
// Already have data in JS array.
|
// Already have data in JS array.
|
||||||
|
@ -104,9 +104,7 @@ impl AudioBuffer {
|
||||||
// Move the channel data from shared_channels to js_channels.
|
// Move the channel data from shared_channels to js_channels.
|
||||||
rooted!(in (cx) let mut array = ptr::null_mut::<JSObject>());
|
rooted!(in (cx) let mut array = ptr::null_mut::<JSObject>());
|
||||||
let shared_channel = (*self.shared_channels.borrow_mut()).buffers.remove(i);
|
let shared_channel = (*self.shared_channels.borrow_mut()).buffers.remove(i);
|
||||||
if unsafe {
|
if Float32Array::create(cx, CreateWith::Slice(&shared_channel), array.handle_mut()).is_err() {
|
||||||
Float32Array::create(cx, CreateWith::Slice(&shared_channel), array.handle_mut())
|
|
||||||
}.is_err() {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
channel.set(array.get());
|
channel.set(array.get());
|
||||||
|
@ -238,7 +236,7 @@ impl AudioBufferMethods for AudioBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
let cx = self.global().get_cx();
|
let cx = self.global().get_cx();
|
||||||
if !self.restore_js_channel_data(cx) {
|
if unsafe { !self.restore_js_channel_data(cx) } {
|
||||||
return Err(Error::JSFailed);
|
return Err(Error::JSFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue