summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehan <jehan@girinstud.io>2022-12-13 23:28:40 +0100
committerJehan <jehan@girinstud.io>2022-12-14 00:24:53 +0100
commitbaeefc095809d87b3d2a45007c3e78e4da74f770 (patch)
tree054ab0ad05013e387b5fd346420df026384f2891
parentb5b75b81cec2fc0b2c131be60086062a8d3af1af (diff)
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.
-rw-r--r--src/nsMBCSGroupProber.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nsMBCSGroupProber.cpp b/src/nsMBCSGroupProber.cpp
index 8388832..8318cbd 100644
--- a/src/nsMBCSGroupProber.cpp
+++ b/src/nsMBCSGroupProber.cpp
@@ -327,8 +327,19 @@ nsProbingState nsMBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen,
else
{
for (PRUint32 i = 0; i < NUM_OF_PROBERS; 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];
+ }
+ }
}
}