mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
OOB protection in GetLineCharAtIdx
This commit is contained in:
parent
6c3944170d
commit
b8c7a29b84
1 changed files with 10 additions and 1 deletions
|
@ -239,7 +239,16 @@ 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