From 611eec135f100ac48a10423d3ee50068f61d87d9 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 1 Jun 2023 11:16:28 +0200 Subject: [PATCH] fix for #519, make sure to not access an not yet initialized transport channel buffer handle --- lib_com/options.h | 1 + lib_dec/lib_dec.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 42d6a6a471..19ca63f927 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -227,6 +227,7 @@ #define FIX_170_DTX_MASA /* Nokia: Fix issue 170, relaxing the use of DTX in MASA format */ #define FIX_510 /* FhG: fix issue 510, misleading error message for invalid input format */ #define FIX_509 /* FhG: fix issue 509, too low number of bitsream indices in SBA */ +#define FIX_519_JBM_ACCESS_NULL_TC_BUFFER /* FhG: fix issue 519, accessing a yet uninitialized TC Buffer in frame 0*/ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 69b6e127fd..fd33c41101 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1084,8 +1084,15 @@ ivas_error IVAS_DEC_GetBufferedNumberOfSamples( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - - *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; +#ifdef FIX_519_JBM_ACCESS_NULL_TC_BUFFER + /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ + if ( hIvasDec->st_ivas->hTcBuffer != NULL ) + { +#endif + *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; +#ifdef FIX_519_JBM_ACCESS_NULL_TC_BUFFER + } +#endif return error; } @@ -1945,7 +1952,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { int16_t nSamplesBuffered; nSamplesBuffered = 0; +#ifdef FIX_519_JBM_ACCESS_NULL_TC_BUFFER + if ( hIvasDec->hasDecodedFirstGoodFrame ) +#else if ( hIvasDec->hasBeenFedFirstGoodFrame ) +#endif { IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ); } -- GitLab