Fix a bug that would end up in memory corruption
Square distances array was not the right size. Copying long words into it would result in fandango on core. Bug: 5508337 Bug: 5591925 Change-Id: I7598081b3cfcd1975b206dada1baf8da9be35641main
parent
fe2d90798e
commit
8c8ca59dd5
|
@ -49,14 +49,17 @@ ProximityInfo::ProximityInfo(const int maxProximityCharsSize, const int keyboard
|
||||||
&& sweetSpotCenterYs && sweetSpotRadii),
|
&& sweetSpotCenterYs && sweetSpotRadii),
|
||||||
mInputXCoordinates(NULL), mInputYCoordinates(NULL),
|
mInputXCoordinates(NULL), mInputYCoordinates(NULL),
|
||||||
mTouchPositionCorrectionEnabled(false) {
|
mTouchPositionCorrectionEnabled(false) {
|
||||||
const int len = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
||||||
mProximityCharsArray = new uint32_t[len];
|
mProximityCharsArray = new uint32_t[proximityGridLength];
|
||||||
mNormalizedSquaredDistances = new int[len];
|
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
LOGI("Create proximity info array %d", len);
|
LOGI("Create proximity info array %d", proximityGridLength);
|
||||||
}
|
}
|
||||||
memcpy(mProximityCharsArray, proximityCharsArray, len * sizeof(mProximityCharsArray[0]));
|
memcpy(mProximityCharsArray, proximityCharsArray,
|
||||||
for (int i = 0; i < len; ++i) {
|
proximityGridLength * sizeof(mProximityCharsArray[0]));
|
||||||
|
const int normalizedSquaredDistancesLength =
|
||||||
|
MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH_INTERNAL;
|
||||||
|
mNormalizedSquaredDistances = new int[normalizedSquaredDistancesLength];
|
||||||
|
for (int i = 0; i < normalizedSquaredDistancesLength; ++i) {
|
||||||
mNormalizedSquaredDistances[i] = NOT_A_DISTANCE;
|
mNormalizedSquaredDistances[i] = NOT_A_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue