add some asserts to delimit the perimeter of CostManager's operation

a small protection in a fairly complex code.

Change-Id: I920e10e1fc1c35da2cf486349417048d516ff2b9
This commit is contained in:
Pascal Massimino 2016-06-15 20:54:52 +02:00
parent 9a583c66f9
commit f2a0946a7a

View File

@ -835,6 +835,7 @@ static WEBP_INLINE void UpdateCost(CostManager* const manager, int i, int index,
double distance_cost) {
int k = i - index;
double cost_tmp;
assert(k >= 0 && k < MAX_LENGTH);
cost_tmp = distance_cost + manager->cost_cache_[k];
if (manager->costs_[i] > cost_tmp) {
@ -1163,6 +1164,7 @@ static int BackwardReferencesHashChainDistanceOnly(
j_max = 1;
} else {
j_max = (int)ceil(cost_manager->min_cost_cache_ / offset_cost);
assert(j_max >= 1);
}
// With the values we currently use for the model, offset_cost is