Pass in string lengths to Gecko_GetAttrAsUTF8.

This commit is contained in:
Cameron McCormack 2016-05-06 11:54:41 +10:00
parent b29ae6383a
commit 603a19929c
2 changed files with 5 additions and 3 deletions

View file

@ -106,8 +106,8 @@ extern "C" {
-> *mut ServoComputedValues;
pub fn Servo_AddRefComputedValues(arg1: *mut ServoComputedValues);
pub fn Servo_ReleaseComputedValues(arg1: *mut ServoComputedValues);
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const u8,
name: *const u8, length: *mut u32)
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const u8, nslen: u32,
name: *const u8, namelen: u32, length: *mut u32)
-> *const ::std::os::raw::c_char;
pub fn Gecko_GetAtomAsUTF16(atom: *mut nsIAtom, length: *mut u32)
-> *const u16;

View file

@ -344,7 +344,9 @@ impl<'le> TElement for GeckoElement<'le> {
fn get_attr<'a>(&'a self, namespace: &Namespace, name: &Atom) -> Option<&'a str> {
unsafe {
let mut length: u32 = 0;
let ptr = Gecko_GetAttrAsUTF8(self.element, namespace.0.as_ptr(), name.as_ptr(), &mut length);
let ptr = Gecko_GetAttrAsUTF8(self.element,
namespace.0.as_ptr(), namespace.0.len() as u32,
name.as_ptr(), name.len() as u32, &mut length);
reinterpret_string(ptr, length)
}
}