diff --git a/src/map/if/acd/ac_decomposition.hpp b/src/map/if/acd/ac_decomposition.hpp index 8d5ddb5c43..c6df54662e 100644 --- a/src/map/if/acd/ac_decomposition.hpp +++ b/src/map/if/acd/ac_decomposition.hpp @@ -482,6 +482,11 @@ class ac_decomposition_impl for ( uint32_t i = 0; i < num_vars; ++i ) { pComb[i] = pInvPerm[i] = i; + /* bestPerm is written only when some combination beats the initial + * best_cost. When none does, the loop below still evaluates + * permutations[bestPerm[i]], which reads uninitialised stack and then + * indexes permutations[] with it. Seed the identity permutation. */ + bestPerm[i] = i; } /* early bail-out conditions */