From a26e278714fe6a59be9042a5c394fc97b1b960d2 Mon Sep 17 00:00:00 2001 From: Akshay Ragir Date: Thu, 16 May 2024 09:41:52 +0530 Subject: [PATCH] Added a fix in the FAC payload writing path - The bit-writing logic had to be skipped when no bits were to be written. Added the missing check for the same. - This change also resolves an issue identified by oss-fuzz Bug: ossFuzz: 68476 Test: poc in bug --- encoder/iusace_enc_fac.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/encoder/iusace_enc_fac.c b/encoder/iusace_enc_fac.c index 6808dbe..bc89007 100644 --- a/encoder/iusace_enc_fac.c +++ b/encoder/iusace_enc_fac.c @@ -520,16 +520,17 @@ WORD32 iusace_fd_encode_fac(WORD32 *prm, WORD16 *ptr_bit_buf, WORD32 fac_length) n = qn - nk * 2; } - if (n != 0) { + if (qn != 0) { iusace_write_bits2buf(I, 4 * n, ptr_bit_buf); ptr_bit_buf += 4 * n; - } - for (j = 0; j < 8; j++) { - iusace_write_bits2buf(kv[j], nk, ptr_bit_buf); - ptr_bit_buf += nk; - } - fac_bits += 4 * qn; + for (j = 0; j < 8; j++) { + iusace_write_bits2buf(kv[j], nk, ptr_bit_buf); + ptr_bit_buf += nk; + } + + fac_bits += 4 * qn; + } } return fac_bits;