From 56e7e38d372c726724c80246e6187dc1241ecfea Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Mon, 16 Dec 2013 22:42:01 +0900 Subject: [PATCH] Fix: incompatible PtNode array size reading. Bug: 11073222 Change-Id: I681be725b5c6dcc10aa536b00327698a7df75277 --- .../latin/makedict/BinaryDictDecoderUtils.java | 8 ++++---- .../inputmethod/latin/makedict/BinaryDictIOUtils.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java index 7f0aa777f..acabea10d 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java @@ -436,7 +436,7 @@ public final class BinaryDictDecoderUtils { final FormatOptions options) { dictDecoder.setPosition(headerSize); final int count = dictDecoder.readPtNodeCount(); - int groupPos = headerSize + BinaryDictIOUtils.getPtNodeCountSize(count); + int groupPos = dictDecoder.getPosition(); final StringBuilder builder = new StringBuilder(); WeightedString result = null; @@ -498,9 +498,9 @@ public final class BinaryDictDecoderUtils { do { // Scan the linked-list node. final int nodeArrayHeadPos = dictDecoder.getPosition(); final int count = dictDecoder.readPtNodeCount(); - int groupOffsetPos = nodeArrayHeadPos + BinaryDictIOUtils.getPtNodeCountSize(count); + int groupPos = dictDecoder.getPosition(); for (int i = count; i > 0; --i) { // Scan the array of PtNode. - PtNodeInfo info = dictDecoder.readPtNode(groupOffsetPos, options); + PtNodeInfo info = dictDecoder.readPtNode(groupPos, options); if (BinaryDictIOUtils.isMovedPtNode(info.mFlags, options)) continue; ArrayList shortcutTargets = info.mShortcutTargets; ArrayList bigrams = null; @@ -536,7 +536,7 @@ public final class BinaryDictDecoderUtils { 0 != (info.mFlags & FormatSpec.FLAG_IS_NOT_A_WORD), 0 != (info.mFlags & FormatSpec.FLAG_IS_BLACKLISTED))); } - groupOffsetPos = info.mEndAddress; + groupPos = info.mEndAddress; } // reach the end of the array. diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 640d778bb..efe1b7b34 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -87,7 +87,7 @@ public final class BinaryDictIOUtils { if (p.mNumOfPtNode == Position.NOT_READ_PTNODE_COUNT) { p.mNumOfPtNode = dictDecoder.readPtNodeCount(); - p.mAddress += getPtNodeCountSize(p.mNumOfPtNode); + p.mAddress = dictDecoder.getPosition(); p.mPosition = 0; } if (p.mNumOfPtNode == 0) {