Commit d8c48662 authored by vaclav's avatar vaclav
Browse files

Merge branch...

Merge branch 'float-1585-asan-memory-leaks-with-format-switching-in-lib_dec-ivas_init_dec-c-2321-53' into 'main'

Resolve "ASAN: memory leaks with format switching in lib_dec/ivas_init_dec.c:2321:53"

See merge request !3002
parents dc3a983f 394bf84a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@
#define FIX_2095_REMOVE_UNUSED_ISAR_TABLES              /* Dolby: remove unused ISAR */
#define FIX_BASOP_2560_STEREO_DFT_DEC_RESET             /* FhG: BASOP issue 2560: align reset of hStereoDft->res_gains_ind_fx[][] between BASOP and float */
#define HARMONIZE_2539_cng_energy                       /* FhG: basop issue 2539: harmonize cng_energy with its ivas derivate */
#define FIX_1585_ASAN_FORMAT_SW_ALT                     /* VA: float issue 1585: alternative fix memory leaks with format switching */

/* #################### End BE switches ################################## */

+24 −0
Original line number Diff line number Diff line
@@ -477,7 +477,9 @@ ivas_error ivas_hp20_dec_reconfig_fx(
)
{
    Word16 i, nchan_hp20;
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    Word32 **old_mem_hp20_out_fx;
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -491,6 +493,18 @@ ivas_error ivas_hp20_dec_reconfig_fx(

    IF( GT_16( nchan_hp20, nchan_hp20_old ) )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* create additional hp20 memories */
        FOR( i = nchan_hp20_old; i < nchan_hp20; i++ )
        {
            IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
            }

            set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;
@@ -519,9 +533,18 @@ ivas_error ivas_hp20_dec_reconfig_fx(

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
#endif
    }
    ELSE IF( LT_16( nchan_hp20, nchan_hp20_old ) )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* remove superfluous hp20 memories */
        FOR( i = nchan_hp20; i < nchan_hp20_old; i++ )
        {
            free( st_ivas->mem_hp20_out_fx[i] );
            st_ivas->mem_hp20_out_fx[i] = NULL;
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;
@@ -546,6 +569,7 @@ ivas_error ivas_hp20_dec_reconfig_fx(

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
#endif
    }

    return error;
+22 −1
Original line number Diff line number Diff line
@@ -2743,6 +2743,7 @@ ivas_error ivas_init_decoder_fx(
    /* set number of output channels used for synthesis/decoding */
    n = getNumChanSynthesis( st_ivas );

#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    IF( n > 0 )
    {
        IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
@@ -2754,7 +2755,7 @@ ivas_error ivas_init_decoder_fx(
    {
        st_ivas->mem_hp20_out_fx = NULL;
    }

#endif
    FOR( i = 0; i < n; i++ )
    {
        IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
@@ -2764,6 +2765,13 @@ ivas_error ivas_init_decoder_fx(
        set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
    }

#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    FOR( ; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        st_ivas->mem_hp20_out_fx[i] = NULL;
    }
#endif

    /*-------------------------------------------------------------------*
     * Allocate and initialize rendering handles
     *--------------------------------------------------------------------*/
@@ -3383,7 +3391,9 @@ void ivas_initialize_handles_dec(
#ifdef FIX_FMSW_DEC
    }
#endif
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    st_ivas->mem_hp20_out_fx = NULL;
#endif
    st_ivas->hLimiter = NULL;

    /* ISM metadata handles */
@@ -3527,6 +3537,16 @@ void ivas_destroy_dec_fx(
    }

    /* HP20 filter handles */
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        IF( st_ivas->mem_hp20_out_fx[i] != NULL )
        {
            free( st_ivas->mem_hp20_out_fx[i] );
            st_ivas->mem_hp20_out_fx[i] = NULL;
        }
    }
#else
    IF( st_ivas->mem_hp20_out_fx != NULL )
    {
        FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
@@ -3537,6 +3557,7 @@ void ivas_destroy_dec_fx(
        free( st_ivas->mem_hp20_out_fx );
        st_ivas->mem_hp20_out_fx = NULL;
    }
#endif

    /* ISM metadata handles */
    ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
+4 −0
Original line number Diff line number Diff line
@@ -1119,7 +1119,11 @@ typedef struct Decoder_Struct
    UWord16 *bit_stream;                                    /* Pointer to bitstream buffer */
    Word16 writeFECoffset;                                  /* parameter for debugging JBM stuff */
    
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    Word32 *mem_hp20_out_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* output signals HP filter memories */
#else
    Word32 **mem_hp20_out_fx;                               /* output signals HP filter memories */
#endif
    IVAS_LIMITER_HANDLE hLimiter;                           /* Limiter handle */

    /* core-decoder modules */