1
0
Fork 0

avformat/iamf_writer: Don't leak on error when adding ParamDefinition

Fix this by postponing the allocation.
Fixes Coverity issue #1559545.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-02-19 19:10:09 +01:00
parent 86410e55ad
commit 94fadd335b
1 changed files with 4 additions and 4 deletions

View File

@ -138,10 +138,6 @@ static IAMFParamDefinition *add_param_definition(IAMFContext *iamf, AVIAMFParamD
iamf->param_definitions = tmp;
param_definition = av_mallocz(sizeof(*param_definition));
if (!param_definition)
return NULL;
if (audio_element)
codec_config = iamf->codec_configs[audio_element->codec_config_id];
@ -160,6 +156,10 @@ static IAMFParamDefinition *add_param_definition(IAMFContext *iamf, AVIAMFParamD
param->constant_subblock_duration = codec_config->nb_samples;
}
param_definition = av_mallocz(sizeof(*param_definition));
if (!param_definition)
return NULL;
param_definition->mode = !!param->duration;
param_definition->param = param;
param_definition->audio_element = audio_element;