Commit 95ff7088 authored by vaclav's avatar vaclav
Browse files

fix issue 701: MSAN: ISM3 decoding hits SEGV in setting output buffers to zero

parent 8988cbf3
Loading
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -179,6 +179,19 @@ ivas_error ivas_dec(

    if ( st_ivas->bfi && st_ivas->ini_frame == 0 )
    {
#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
        for ( n = 0; n < nchan_out; n++ )
        {
            /* note: these are intra-frame heap memories */
            if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
            }
            output[n] = st_ivas->p_output_f[n];
            p_output[n] = output[n];
        }
#endif

        /* zero output when first frame(s) is lost */
        for ( n = 0; n < nchan_out; n++ )
        {
@@ -1255,6 +1268,18 @@ ivas_error ivas_dec(
    st_ivas->last_ivas_format = st_ivas->ivas_format;
#endif

#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
    /* in case first frame(s) was/were lost, deallocate output buffers */
    if ( st_ivas->bfi && st_ivas->ini_frame == 0 )
    {
        for ( n = 0; n < nchan_out; n++ )
        {
            free( st_ivas->p_output_f[n] );
            st_ivas->p_output_f[n] = NULL;
        }
    }
#endif

#ifdef DEBUG_MODE_INFO
    dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" );
    dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" );