Commit a56d6cb170 for aom
commit a56d6cb170003a186c70f9e3771d04622a71ec44
Author: Wan-Teh Chang <wtc@google.com>
Date: Fri Dec 12 11:16:28 2025 -0800
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 415799e9b7..e68938561a 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 @@ void av1_finalize_encoded_frame(AV1_COMP *const cpi) {
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];