Skip to content

Commit

Permalink
Fix crash when seeing 256 '['
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Sep 6, 2021
1 parent 8b8b77a commit ff9f814
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/tree_sitter_markdown/block_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ unsigned BlockContextStack::deserialize(const unsigned char *buffer) {
}

void BlockContextStack::push(const BlockContext &ctx) {
TREE_SITTER_MARKDOWN_ASSERT(stk_.size() < 255);
stk_.push_back(ctx);
}
void BlockContextStack::pop() {
Expand Down
3 changes: 2 additions & 1 deletion src/tree_sitter_markdown/block_delimiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void BlockDelimiterList::drop_pos() {
unsigned BlockDelimiterList::serialize(unsigned char *buffer) const {
size_t i = 0;
size_t size_i = i++;
size_t size = 0;
unsigned char size = 0;
for (ConstIterator itr = list_.begin(), end = list_.end(); itr != end; itr++) {
i += itr->serialize(&buffer[i]);
size++;
Expand All @@ -160,6 +160,7 @@ unsigned BlockDelimiterList::deserialize(const unsigned char *buffer) {
void BlockDelimiterList::pop_front() { list_.pop_front(); }
void BlockDelimiterList::push_back(const BlockDelimiter &dlm) { list_.push_back(dlm); }
BlockDelimiterList::Iterator BlockDelimiterList::insert(const BlockDelimiterList::Iterator itr, const BlockDelimiter &dlm) {
TREE_SITTER_MARKDOWN_ASSERT(list_.size() < 255);
return list_.insert(itr, dlm);
}
BlockDelimiterList::Iterator BlockDelimiterList::insert(const LexedRow row, const BlockDelimiter &dlm) {
Expand Down
7 changes: 5 additions & 2 deletions src/tree_sitter_markdown/inline_delimiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,16 @@ bool MinimizedInlineDelimiterList::empty() const { return list_.empty(); }
MinimizedInlineDelimiter &MinimizedInlineDelimiterList::front() { return list_.front(); }

void MinimizedInlineDelimiterList::pop_front() { list_.pop_front(); }
void MinimizedInlineDelimiterList::push_back(const MinimizedInlineDelimiter &delimiter) { list_.push_back(delimiter); }
void MinimizedInlineDelimiterList::push_back(const MinimizedInlineDelimiter &delimiter) {
TREE_SITTER_MARKDOWN_ASSERT(list_.size() < 255);
list_.push_back(delimiter);
}

void MinimizedInlineDelimiterList::clear() { list_.clear(); }
unsigned MinimizedInlineDelimiterList::serialize(unsigned char *buffer) const {
size_t i = 0;
size_t size_i = i++;
size_t size = 0;
unsigned char size = 0;
for (ConstIterator itr = list_.begin(), end = list_.end(); itr != end; itr++) {
i += itr->serialize(&buffer[i]);
size++;
Expand Down

0 comments on commit ff9f814

Please sign in to comment.