mirror of
https://github.com/ivuorinen/tree-sitter-shellspec.git
synced 2026-02-15 04:52:22 +00:00
feat: add post-generation script to preserve buffer overflow fix
Created scripts/post-generate.sh that automatically re-applies the critical buffer overflow fix to parser.h after tree-sitter generate runs. This fix prevents undefined behavior in set_contains() when accessing an empty array. The script is automatically executed after tree-sitter generate via the npm generate script. Added generate:only for cases where post-processing should be skipped.
This commit is contained in:
@@ -7923,4 +7923,4 @@
|
||||
"_primary_expression"
|
||||
],
|
||||
"reserved": {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3307,4 +3307,4 @@
|
||||
"type": "~",
|
||||
"named": false
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -62,7 +62,7 @@ extern "C" {
|
||||
/// Push a new `element` onto the end of the array.
|
||||
#define array_push(self, element) \
|
||||
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
||||
(self)->contents[(self)->size++] = (element))
|
||||
(self)->contents[(self)->size++] = (element))
|
||||
|
||||
/// Increase the array's size by `count` elements.
|
||||
/// New elements are zero-initialized.
|
||||
@@ -218,8 +218,8 @@ static inline void _array__grow(Array *self, uint32_t count, size_t element_size
|
||||
|
||||
/// This is not what you're looking for, see `array_splice`.
|
||||
static inline void _array__splice(Array *self, size_t element_size,
|
||||
uint32_t index, uint32_t old_count,
|
||||
uint32_t new_count, const void *elements) {
|
||||
uint32_t index, uint32_t old_count,
|
||||
uint32_t new_count, const void *elements) {
|
||||
uint32_t new_size = self->size + new_count - old_count;
|
||||
uint32_t old_end = index + old_count;
|
||||
uint32_t new_end = index + new_count;
|
||||
|
||||
@@ -152,6 +152,7 @@ struct TSLanguage {
|
||||
};
|
||||
|
||||
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||
if (len == 0) return false;
|
||||
uint32_t index = 0;
|
||||
uint32_t size = len - index;
|
||||
while (size > 1) {
|
||||
|
||||
Reference in New Issue
Block a user