diff options
author | Jehan <jehan@girinstud.io> | 2022-12-13 23:28:40 +0100 |
---|---|---|
committer | Jehan <jehan@girinstud.io> | 2022-12-14 00:24:53 +0100 |
commit | baeefc095809d87b3d2a45007c3e78e4da74f770 (patch) | |
tree | 054ab0ad05013e387b5fd346420df026384f2891 | |
parent | b5b75b81cec2fc0b2c131be60086062a8d3af1af (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.cpp | 11 |
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]; + } + } } } |