mirror of
https://gitlab.freedesktop.org/uchardet/uchardet.git
synced 2025-12-06 16:56:40 +08:00
src: process pending language data when we are going to pass buffer size.
We were experiencing segmentation fault when processing long texts because we were ending up trying to access out-of-range data (from codePointBuffer). Verify when this will happen and process data to reset the index before adding more code points.
This commit is contained in:
parent
b5b75b81ce
commit
baeefc0958
@ -327,8 +327,19 @@ nsProbingState nsMBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
|
||||||
|
{
|
||||||
if (codePointBuffer[i])
|
if (codePointBuffer[i])
|
||||||
|
{
|
||||||
|
if (codePointBufferIdx[i] == codePointBufferSize[i] - 1)
|
||||||
|
{
|
||||||
|
for (PRUint32 j = 0; j < NUM_OF_LANGUAGES; j++)
|
||||||
|
langDetectors[i][j]->HandleData(codePointBuffer[i], codePointBufferIdx[i]);
|
||||||
|
codePointBufferIdx[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
codePointBuffer[i][(codePointBufferIdx[i])++] = aBuf[pos];
|
codePointBuffer[i][(codePointBufferIdx[i])++] = aBuf[pos];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user