Skip to content

Commit 9abf2ae

Browse files
committed
avformat/iamf_parse: ensure there's at most one of each parameter types in audio elements
Should prevent potential memory leaks on invalid files. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 5470d02)
1 parent b06845c commit 9abf2ae

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

libavformat/iamf_parse.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,19 @@ static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
747747
type = ffio_read_leb(pbc);
748748
if (type == AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN)
749749
ret = AVERROR_INVALIDDATA;
750-
else if (type == AV_IAMF_PARAMETER_DEFINITION_DEMIXING)
750+
else if (type == AV_IAMF_PARAMETER_DEFINITION_DEMIXING) {
751+
if (element->demixing_info) {
752+
ret = AVERROR_INVALIDDATA;
753+
goto fail;
754+
}
751755
ret = param_parse(s, c, pbc, type, audio_element, &element->demixing_info);
752-
else if (type == AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN)
756+
} else if (type == AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN) {
757+
if (element->recon_gain_info) {
758+
ret = AVERROR_INVALIDDATA;
759+
goto fail;
760+
}
753761
ret = param_parse(s, c, pbc, type, audio_element, &element->recon_gain_info);
754-
else {
762+
} else {
755763
unsigned param_definition_size = ffio_read_leb(pbc);
756764
avio_skip(pbc, param_definition_size);
757765
}

0 commit comments

Comments
 (0)