servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

TypedArray::from method should protect against null pointers #332

Closed jdm closed 7 years ago

jdm commented 7 years ago

We should add a testcase to tests/typedarray.rs that uses the typedarray! macro on ptr::null_mut(), and write code that correctly returns an Err value if that's encountered.

Code: src/typedarray.rs

zakorgy commented 7 years ago

@jdm I would like to try this.

emilio commented 7 years ago

Nice! Let us know if you need any help :)

zakorgy commented 7 years ago

Thanks @emilio. If I'm correct, the test case should be look like this:

        rooted!(in(cx) let rval = ptr::null_mut());
        typedarray!(in(cx) let array: Uint8Array = rval.get());
        assert!(array.is_err());
jdm commented 7 years ago

That looks right!