mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
OOB protection in GetLineCharAtIdx
This commit is contained in:
parent
6c3944170d
commit
b8c7a29b84
1 changed files with 10 additions and 1 deletions
|
@ -240,6 +240,15 @@ int BfParserData::GetCharIdAtIndex(int findIndex)
|
|||
|
||||
void BfParserData::GetLineCharAtIdx(int idx, int& line, int& lineChar)
|
||||
{
|
||||
if (mJumpTableSize <= 0)
|
||||
{
|
||||
line = 0;
|
||||
lineChar = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (idx >= mSrcLength)
|
||||
idx = mSrcLength - 1;
|
||||
auto* jumpEntry = mJumpTable + (idx / PARSER_JUMPTABLE_DIVIDE);
|
||||
if (jumpEntry->mCharIdx > idx)
|
||||
jumpEntry--;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue