parent
1d6262dfd7
commit
4269f09f73
@ -1,49 +0,0 @@
|
|||||||
From fe33599f4695c4ab442e1e5f8682cfda11321308 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aleksei Bavshin <alebastr89@gmail.com>
|
|
||||||
Date: Tue, 22 Mar 2022 22:47:21 -0700
|
|
||||||
Subject: [PATCH] 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'
|
|
||||||
```
|
|
||||||
---
|
|
||||||
lib/binding_rust/lib.rs | 6 +++---
|
|
||||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/binding_rust/lib.rs b/binding_rust/lib.rs
|
|
||||||
index e88a411c..1df9e7ac 100644
|
|
||||||
--- a/binding_rust/lib.rs
|
|
||||||
+++ b/binding_rust/lib.rs
|
|
||||||
@@ -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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.35.1
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
SHA512 (tree-sitter-0.20.6.crate) = b1c7425db2903b889c90cd283ab557ad34d0dead01ec1313571fd537f2b783df88849caf4f253d27c65cd84fc43eeb3c5073e2df876b5a5d716186563b37b92a
|
SHA512 (tree-sitter-0.20.9.crate) = 03e38b5252dd94b65c096ba9d07e6aecbb582c8460e2f1e0ad46122e372be7139462d7c411094ba557abd6566bd89faeaf7ff01bddb9283d2d7285d13e38c5a6
|
||||||
|
Loading…
Reference in new issue