]> git.sesse.net Git - ffmpeg/commit
avformat/segment: Fix segfault on allocation error, avoid allocation
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 6 Sep 2020 10:34:58 +0000 (12:34 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 10 Sep 2020 11:43:43 +0000 (13:43 +0200)
commit06f99cc4ddbb16f8fd9ae3d72835d542be3dbab2
tree11a03c037d1943e2d9bdec8a3229f53aceed5c13
parent4b836c86132feb67ca10e383988884dd67bcd19a
avformat/segment: Fix segfault on allocation error, avoid allocation

If the user has set none of the options specifying the segments'
durations, a default value of 2s is used by duplicating a "2" string and
using av_parse_time() on it. Yet duplicating the string was unchecked
and if the allocation failed, one would get a segfault in
av_parse_time().

This commit solves this by turning said option into an option of type
AV_OPT_TYPE_DURATION (which also uses av_parse_time() internally),
avoiding duplicating the string altogether.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/segment.c