Do not index costs out of bounds.

In practice, the value is never read.

Change-Id: Idb33dad2581e597bd5e5b5c9414ae2c34f3a8ef2
This commit is contained in:
Vincent Rabaud
2025-11-04 10:24:45 +01:00
parent 2d16e4ac95
commit 2760d87827

View File

@@ -646,7 +646,13 @@ static int TrellisQuantizeBlock(const VP8Encoder* WEBP_RESTRICT const enc,
int best_prev;
score_t cost, score;
ss_cur[m].costs = costs[n + 1][ctx];
// costs is [16][NUM_CTX == 3] but ss_cur[m].costs is only read after
// being swapped with ss_prev: the last value can be NULL.
if (n + 1 < 16) {
ss_cur[m].costs = costs[n + 1][ctx];
} else {
ss_cur[m].costs = NULL;
}
if (level < 0 || level > thresh_level) {
ss_cur[m].score = MAX_COST;
// Node is dead.