Commit ed355697 authored by emerit's avatar emerit
Browse files

fix memory leaks

parent 2e04d577
Loading
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -1155,6 +1155,7 @@ static ivas_error load_reverb_from_binary(
        {
            if ( hrtf_header.frequency != sampleRate )
            {
                free( hrtf_data );
                return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE;
            }
        }
@@ -1319,11 +1320,17 @@ static ivas_error TDREND_MIX_LoadHRTF(
    {
        if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK )
        {
#ifdef FIX_989_TD_REND_ROM
            free( hrtf_data );
#endif
            return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "HRTF binary file not compliant (number of HRTF)" );
        }

        if ( ( header_check_result = check_hrtf_binary_header( &hrtf_header ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_989_TD_REND_ROM
            free( hrtf_data );
#endif
            return header_check_result;
        }

@@ -1332,6 +1339,9 @@ static ivas_error TDREND_MIX_LoadHRTF(
        {
            if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size )
            {
#ifdef FIX_989_TD_REND_ROM
                free( hrtf_data );
#endif
                return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
            }
        }
@@ -1340,6 +1350,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
        {
            if ( hrtf_header.frequency != sampleRate )
            {
                free( hrtf_data );
                return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE;
            }
        }
@@ -2902,6 +2913,7 @@ ivas_error load_fastconv_HRTF_from_binary(
        {
            if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */
            {
                free( hrtf_data );
                return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE;
            }
#else
@@ -3095,6 +3107,7 @@ ivas_error load_parambin_HRTF_from_binary(
#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( hrtf_header.frequency != 48000 ) /* note: Parametric renderer data are always stored at 48 kHz */
            {
                free( hrtf_data );
                return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE;
            }
#endif
@@ -3158,6 +3171,7 @@ ivas_error load_Crend_HRTF_from_binary(
    ivas_hrtfs_file_header_t hrtfs_file_header;
    int16_t hrtf_id;
    bool load = false;
    int16_t asCrend = 0;
    BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg;

    /* convert audio config. to HRTF binaural config */
@@ -3218,6 +3232,7 @@ ivas_error load_Crend_HRTF_from_binary(
        {
            if ( hrtf_header.frequency != sampleRate )
            {
                free( hrtf_data );
                return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE;
            }

@@ -3232,7 +3247,7 @@ ivas_error load_Crend_HRTF_from_binary(
                free( hrtf_data );
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" );
            }

            asCrend = 1;
            break; /* read just one set */
        }
        else
@@ -3243,8 +3258,15 @@ ivas_error load_Crend_HRTF_from_binary(

    free( hrtf_data );

    if ( asCrend )
    {
        return IVAS_ERR_OK;
    }
    else
    {
        return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" );
    }
}
#else

/*---------------------------------------------------------------------*