From 5698415704f5044a63b0d9b97b61e4142f7c8cf8 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 16 Dec 2025 11:34:05 +0100 Subject: [PATCH 1/2] FIX_BASOP_2288_VBAP_MALLOC: fix malloc computation for VBAP triplets --- lib_com/options.h | 1 + lib_rend/ivas_vbap_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 24a8afca1..dfd3617e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,7 @@ #define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ +#define FIX_BASOP_2288_VBAP_MALLOC /* FhG/Nok: fix allocation size warning for VBAP triplets */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index fdbd4f530..2fd95011f 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -363,7 +363,15 @@ ivas_error vbap_init_data_fx( } } +#ifdef FIX_BASOP_2288_VBAP_MALLOC + Word16 num_triplets = 0; + num_triplets = s_max( 0, ( ( speaker_nodes_group1_internal - 2 ) * 2 - ( s_max( 0, ( speaker_nodes_horiz_internal - 2 ) ) ) ) ); + move16(); + + IF( ( vbap->search_struct[0].triplets = (VBAP_VS_TRIPLET *) malloc( num_triplets * sizeof( VBAP_VS_TRIPLET ) ) ) == NULL ) +#else IF( ( vbap->search_struct[0].triplets = (VBAP_VS_TRIPLET *) malloc( ( ( speaker_nodes_group1_internal - 2 ) * 2 - ( s_max( 0, ( speaker_nodes_horiz_internal - 2 ) ) ) ) * sizeof( VBAP_VS_TRIPLET ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VBAP data\n" ) ); } -- GitLab From 656bfd629636dd106ebf527381935f1e7be843b7 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 17 Dec 2025 12:17:43 +0200 Subject: [PATCH 2/2] Cleanup parentheses and duplicate fix for second search struct. --- lib_rend/ivas_vbap_fx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index 2fd95011f..2194e7775 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -365,7 +365,7 @@ ivas_error vbap_init_data_fx( #ifdef FIX_BASOP_2288_VBAP_MALLOC Word16 num_triplets = 0; - num_triplets = s_max( 0, ( ( speaker_nodes_group1_internal - 2 ) * 2 - ( s_max( 0, ( speaker_nodes_horiz_internal - 2 ) ) ) ) ); + num_triplets = s_max( 0, ( speaker_nodes_group1_internal - 2 ) * 2 - s_max( 0, speaker_nodes_horiz_internal - 2 ) ); move16(); IF( ( vbap->search_struct[0].triplets = (VBAP_VS_TRIPLET *) malloc( num_triplets * sizeof( VBAP_VS_TRIPLET ) ) ) == NULL ) @@ -381,7 +381,14 @@ ivas_error vbap_init_data_fx( { vbap->num_search_structs = 2; move16(); +#ifdef FIX_BASOP_2288_VBAP_MALLOC + num_triplets = s_max( 0, ( speaker_nodes_group2_internal - 2 ) * 2 - s_max( 0, speaker_nodes_horiz_internal - 2 ) ); + move16(); + + IF( ( vbap->search_struct[1].triplets = (VBAP_VS_TRIPLET *) malloc( num_triplets * sizeof( VBAP_VS_TRIPLET ) ) ) == NULL ) +#else IF( ( vbap->search_struct[1].triplets = (VBAP_VS_TRIPLET *) malloc( ( ( speaker_nodes_group2_internal - 2 ) * 2 - ( s_max( 0, ( speaker_nodes_horiz_internal - 2 ) ) ) ) * sizeof( VBAP_VS_TRIPLET ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VBAP data\n" ) ); } -- GitLab