Commit 442884c8 authored by Jan Brouwer's avatar Jan Brouwer
Browse files

fix allocation size error in render_config_reader.c

parent 52458afa
Loading
Loading
Loading
Loading
+31 −32
Original line number Diff line number Diff line
@@ -1432,15 +1432,15 @@ static ivas_error RenderConfigReader_readBinary(

    /* Allocate memory for the frequency grids */
    if ( nFG > 0 )
    {
        if ( pRenderConfigReader->nFG > 0 )
    {
        for ( n = 0; n < pRenderConfigReader->nFG; n++ )
        {
            free( pRenderConfigReader->pFG[n].pFc );
        }
        free( pRenderConfigReader->pFG );
        }

        pRenderConfigReader->nFG = nFG;

        if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL )
        {
            return IVAS_ERR_FAILED_ALLOC;
@@ -1450,7 +1450,6 @@ static ivas_error RenderConfigReader_readBinary(
            /* Initialize memory pointers to allow safe freeing ico errors */
            pRenderConfigReader->pFG[n].pFc = NULL;
        }
        pRenderConfigReader->nFG = nFG;
    }

    /* Loop through the frequency grids read from the binary stream */
@@ -1617,8 +1616,6 @@ static ivas_error RenderConfigReader_readBinary(

    /* Allocate memory for the acoustic environments array */
    if ( nAE > 0 )
    {
        if ( pRenderConfigReader->nAE > 0 )
    {
        for ( n = 0; n < pRenderConfigReader->nAE; n++ )
        {
@@ -1633,13 +1630,13 @@ static ivas_error RenderConfigReader_readBinary(
#endif
        }
        free( pRenderConfigReader->pAE );
        }

        pRenderConfigReader->nAE = nAE;

        if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL )
        {
            return IVAS_ERR_FAILED_ALLOC;
        }
        pRenderConfigReader->nAE = nAE;
        /* Initialize memory pointers to allow safe freeing ico errors */
        for ( n = 0; n < nAE; n++ )
        {
@@ -2000,8 +1997,9 @@ ivas_error RenderConfigReader_read(
#endif
                            }
                            free( pRenderConfigReader->pAE );

                            pRenderConfigReader->nAE = nAE;
                        }

                            /* Allocate memory for the acoustic environments array */
                            if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL )
                            {
@@ -2016,6 +2014,7 @@ ivas_error RenderConfigReader_read(
                                pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL;
#endif
                            }
                        }
                        acIdx = 0;
                        roomAcHasAcEnvCount = TRUE;
                    }