lib: fix incorrect int ptr cast on big-endian architectures
`*usize` -> `*u32` conversion on 64-bit big-endian machine takes high
halfword of the value. As a consequence, any result returned via
`count` is unexpectedly shifted left:
u32 = 00 00 00 01 // 1
usize = 00 00 00 01 00 00 00 00 // 4294967296
Fixes following test failure:
```
$ cargo test -- tests::corpus_test
<...>
running 13 tests
memory allocation of 206158430208 bytes failed
error: test failed, to rerun pass '--lib'
```
This commit is contained in:
parent
cdf2ecd176
commit
fe33599f46
1 changed files with 3 additions and 3 deletions
|
|
@ -705,14 +705,14 @@ impl Tree {
|
|||
/// after calling one of the [Parser::parse] functions. Call it on the old tree that
|
||||
/// was passed to parse, and pass the new tree that was returned from `parse`.
|
||||
pub fn changed_ranges(&self, other: &Tree) -> impl ExactSizeIterator<Item = Range> {
|
||||
let mut count = 0;
|
||||
let mut count = 0u32;
|
||||
unsafe {
|
||||
let ptr = ffi::ts_tree_get_changed_ranges(
|
||||
self.0.as_ptr(),
|
||||
other.0.as_ptr(),
|
||||
&mut count as *mut _ as *mut u32,
|
||||
&mut count as *mut u32,
|
||||
);
|
||||
util::CBufferIter::new(ptr, count).map(|r| r.into())
|
||||
util::CBufferIter::new(ptr, count as usize).map(|r| r.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue