Commit 45e82ca3 authored by vaclav's avatar vaclav
Browse files

Merge branch '98-setting-of-decoder-handles-to-null-rev1' into 'main'

fix 'st_ivas' deallocation in case of early exit

See merge request !139
parents 7416232d 181740eb
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -427,25 +427,25 @@ int main(
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" );
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n\n" );
            goto cleanup;
        }

        if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n", arg.renderConfigFilename );
            fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename );
            goto cleanup;
        }

        if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
    }
+17 −2
Original line number Diff line number Diff line
@@ -250,9 +250,20 @@ void IVAS_DEC_Close(
    if ( ( *phIvasDec )->hVoIP )
    {
        IVAS_DEC_Close_VoIP( ( *phIvasDec )->hVoIP );
#ifdef FIX_I98_HANDLES_TO_NULL
        ( *phIvasDec )->hVoIP = NULL;
#else
        count_free( ( *phIvasDec )->hVoIP );
#endif
    }

#ifdef FIX_I98_HANDLES_TO_NULL
    if ( ( *phIvasDec )->st_ivas )
    {
        ivas_destroy_dec( ( *phIvasDec )->st_ivas );
        ( *phIvasDec )->st_ivas = NULL;
    }
#else
    if ( ( *phIvasDec )->isInitialized )
    {
        if ( ( *phIvasDec )->st_ivas )
@@ -268,7 +279,7 @@ void IVAS_DEC_Close(
            ( *phIvasDec )->st_ivas->hDecoderConfig = NULL;
        }

#ifndef FIX_I98_HANDLES_TO_NULL

        if ( ( *phIvasDec )->st_ivas->hHeadTrackData != NULL )
        {
            count_free( ( *phIvasDec )->st_ivas->hHeadTrackData );
@@ -278,11 +289,11 @@ void IVAS_DEC_Close(
        ivas_render_config_close( &( ( *phIvasDec )->st_ivas->hRenderConfig ) );

        ivas_HRTF_binary_close( &( *phIvasDec )->st_ivas->hHrtfTD );
#endif
        count_free( ( *phIvasDec )->st_ivas );
    }

    ( *phIvasDec )->st_ivas = NULL;
#endif

    count_free( *phIvasDec );
    *phIvasDec = NULL;
@@ -1489,6 +1500,10 @@ static void IVAS_DEC_Close_VoIP(

    pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler );

#ifdef FIX_I98_HANDLES_TO_NULL
    count_free( hVoIP );
#endif

    return;
}