mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/prism] Only read from buffer if size
is greater than 0
It looks like we can possibly do an out of bounds read if size is equal
to 0. This commit adds a conditional to ensure size is actually greater
than 0 before looking backwards in the buffer
2031b626e6
This commit is contained in:
parent
83568a41af
commit
3c9be02af1
1 changed files with 1 additions and 1 deletions
|
@ -185,7 +185,7 @@ pm_strspn_number_kind_underscores(const uint8_t *string, ptrdiff_t length, const
|
|||
size++;
|
||||
}
|
||||
|
||||
if (string[size - 1] == '_') *invalid = string + size - 1;
|
||||
if (size > 0 && string[size - 1] == '_') *invalid = string + size - 1;
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue