[FFmpeg-devel] [PATCH 1/5] avformat/iamf_writer: Don't leak on error when adding ParamDefinition
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Mon Feb 19 23:51:17 EET 2024
Fix this by postponing the allocation.
Fixes Coverity issue #1559545.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavformat/iamf_writer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 1a360dee2f..897b06310f 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -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;
--
2.34.1
More information about the ffmpeg-devel
mailing list