Assert cpi->existing_fb_idx_to_show is valid index
In av1_finalize_encoded_frame(), assert that
cpi->existing_fb_idx_to_show is a valid index for the cm->ref_frame_map
array.
Hopefully this will suppress Coverity defect CID 555118:
Improper use of negative value (NEGATIVE_RETURNS)
Change-Id: I6e0377dd4d12c5b39e8a8b9391ea52bc80148c19
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index 415799e..e689385 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
+#include <assert.h>
#include <string.h>
#include "aom/aomcx.h"
@@ -1317,6 +1318,8 @@
if (!cm->seq_params->reduced_still_picture_hdr &&
encode_show_existing_frame(cm)) {
+ assert(cpi->existing_fb_idx_to_show >= 0 &&
+ cpi->existing_fb_idx_to_show < REF_FRAMES);
RefCntBuffer *const frame_to_show =
cm->ref_frame_map[cpi->existing_fb_idx_to_show];