shithub: opus

Download patch

ref: 4a344aff026079af4478c77ec54d2573fd6ec85f
parent: 5a29ca93acc1b165498e1d8938d7bdfdf89c167a
author: Jean-Marc Valin <jeanmarcv@google.com>
date: Mon Mar 17 10:15:37 EDT 2025

Work around a clang VLA issue

--- a/silk/decode_core.c
+++ b/silk/decode_core.c
@@ -58,7 +58,13 @@
     ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 );
     ALLOC( sLTP_Q15, psDec->ltp_mem_length + psDec->frame_length, opus_int32 );
     ALLOC( res_Q14, psDec->subfr_length, opus_int32 );
+    /* Work around a clang bug (verified with clang 6.0 through clang 20.1.0) that causes the last
+       memset to be flagged as an invalid read by valgrind (not caught by asan). */
+#if defined(__clang__) && defined(VAR_ARRAYS)
+    ALLOC( sLPC_Q14, MAX_SUB_FRAME_LENGTH + MAX_LPC_ORDER, opus_int32 );
+#else
     ALLOC( sLPC_Q14, psDec->subfr_length + MAX_LPC_ORDER, opus_int32 );
+#endif
 
     offset_Q10 = silk_Quantization_Offsets_Q10[ psDec->indices.signalType >> 1 ][ psDec->indices.quantOffsetType ];
 
--