diff options
author | 2013-09-09 23:47:23 -0700 | |
---|---|---|
committer | 2013-09-09 23:47:23 -0700 | |
commit | 0f2fe443a134d6e298a14e46c9d5bcc6d6709f36 (patch) | |
tree | 2679120b11d7983401033e216cd4e90debf74b08 | |
parent | 5599b04a0b7ed3fbc07f9b51518c67f884b85618 (diff) | |
parent | 210669605a544d5384d1f88af96b56c5fc57652d (diff) | |
download | latinime-0f2fe443a134d6e298a14e46c9d5bcc6d6709f36.tar.gz latinime-0f2fe443a134d6e298a14e46c9d5bcc6d6709f36.tar.xz latinime-0f2fe443a134d6e298a14e46c9d5bcc6d6709f36.zip |
am 21066960: Merge "Fix: ExtendableBuffer"
* commit '210669605a544d5384d1f88af96b56c5fc57652d':
Fix: ExtendableBuffer
-rw-r--r-- | native/jni/src/suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.cpp b/native/jni/src/suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.cpp index 6326754c2..dfdaebd18 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.cpp @@ -66,16 +66,17 @@ bool BufferWithExtendableBuffer::writeCodePointsAndAdvancePosition(const int *co bool BufferWithExtendableBuffer::checkAndPrepareWriting(const int pos, const int size) { if (isInAdditionalBuffer(pos)) { - if (pos == mUsedAdditionalBufferSize) { + const int tailPosition = getTailPosition(); + if (pos == tailPosition) { // Append data to the tail. - if (pos + size > static_cast<int>(mAdditionalBuffer.size())) { + if (pos + size > static_cast<int>(mAdditionalBuffer.size()) + mOriginalBufferSize) { // Need to extend buffer. if (!extendBuffer()) { return false; } } mUsedAdditionalBufferSize += size; - } else if (pos + size >= mUsedAdditionalBufferSize) { + } else if (pos + size >= tailPosition) { // The access will beyond the tail of used region. return false; } |