aboutsummaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorYusuke Nojima <nojima@google.com>2011-09-16 11:28:54 +0900
committerYusuke Nojima <nojima@google.com>2011-09-16 11:52:16 +0900
commit2e496f5d0b0a2a065e5f8162619c98b42bca1905 (patch)
treeb6ad55c4f5c3e1b847ab2b4e113361f917562f6a /native/src
parent5b0c124ca888ee4ecbde9a51f11c4e9887a96636 (diff)
downloadlatinime-2e496f5d0b0a2a065e5f8162619c98b42bca1905.tar.gz
latinime-2e496f5d0b0a2a065e5f8162619c98b42bca1905.tar.xz
latinime-2e496f5d0b0a2a065e5f8162619c98b42bca1905.zip
Fix editDistance() not to access the outside of mEditDistanceTable
editDistance() can access the outside of mEditDistanceTable when called with strings that contain MAX_WORD_LENGTH_INTERNAL characters. Change-Id: I996e6cf21bd6acd6584beb4046c10491a044191e
Diffstat (limited to 'native/src')
-rw-r--r--native/src/correction.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/native/src/correction.h b/native/src/correction.h
index f3194b788..41130ad77 100644
--- a/native/src/correction.h
+++ b/native/src/correction.h
@@ -119,8 +119,9 @@ private:
int mTerminalInputIndex;
int mTerminalOutputIndex;
unsigned short mWord[MAX_WORD_LENGTH_INTERNAL];
+ // Edit distance calculation requires a buffer with (N+1)^2 length for the input length N.
// Caveat: Do not create multiple tables per thread as this table eats up RAM a lot.
- int mEditDistanceTable[MAX_WORD_LENGTH_INTERNAL * MAX_WORD_LENGTH_INTERNAL];
+ int mEditDistanceTable[(MAX_WORD_LENGTH_INTERNAL + 1) * (MAX_WORD_LENGTH_INTERNAL + 1)];
CorrectionState mCorrectionStates[MAX_WORD_LENGTH_INTERNAL];