From 2424a976a408112e24f2eed1617d246025b15fab Mon Sep 17 00:00:00 2001 From: Ari Lemmetti Date: Fri, 10 Dec 2021 00:21:58 +0200 Subject: [PATCH] Prevent using uninitialized memory --- src/search_inter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/search_inter.c b/src/search_inter.c index e670683c..59aa7342 100644 --- a/src/search_inter.c +++ b/src/search_inter.c @@ -1759,7 +1759,10 @@ static void search_pu_inter(encoder_state_t * const state, kvz_sort_keys_by_cost(&amvp[0]); kvz_sort_keys_by_cost(&amvp[1]); - int best_keys[2] = { amvp[0].keys[0], amvp[1].keys[0] }; + int best_keys[2] = { + amvp[0].size > 0 ? amvp[0].keys[0] : 0, + amvp[1].size > 0 ? amvp[1].keys[0] : 0 + }; cu_info_t *best_unipred[2] = { &amvp[0].unit[best_keys[0]],