ffmpeg/fftools
Andreas Rheinhardt 0cf474451d
fftools/ffmpeg_mux_init: Fix double-free on error
MATCH_PER_STREAM_OPT iterates over all options of a given
OptionDef and tests whether they apply to the current stream;
if so, they are set to ost->apad, otherwise, the code errors
out. If no error happens, ost->apad is av_strdup'ed in order
to take ownership of this pointer.

But this means that setting it originally was premature,
as it leads to double-frees when an error happens lateron.
This can simply be reproduced with
ffmpeg -filter_complex anullsrc  -apad bar -apad:n baz -f null -
This is a regression since 83ace80bfd.

Fix this by using a temporary variable instead of directly
setting ost->apad. Also only strdup the string if it actually
is != NULL.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit ced5c5fdb8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8a1ccbd5dd76fb12ad75528038a9f7f50fee330d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-30 21:38:23 +01:00
..
cmdutils.c fftools/cmdutils: Add protective () to FLAGS 2024-06-15 23:32:58 +02:00
cmdutils.h fftools: Switch to const AVCodec * where possible 2021-03-02 08:20:10 +01:00
ffmpeg.c fftools/ffmpeg: Check read() for failure 2024-07-21 18:55:35 +02:00
ffmpeg.h fftools/ffmpeg: use av_packet_alloc() to allocate packets 2021-03-17 15:19:38 -03:00
ffmpeg_filter.c fftools/ffmpeg_filter: Don't use deprecated function 2021-02-26 18:28:26 +01:00
ffmpeg_hw.c ffmpeg: Don't require a known device to pass a frames context to an encoder 2020-05-03 16:04:27 +01:00
ffmpeg_opt.c fftools/ffmpeg_mux_init: Fix double-free on error 2025-11-30 21:38:23 +01:00
ffmpeg_qsv.c ffmpeg: Remove the hw_device_ctx global 2020-04-26 18:38:25 +01:00
ffmpeg_videotoolbox.c Stop hardcoding align=32 in av_frame_get_buffer() calls. 2020-05-22 14:38:57 +02:00
ffplay.c fftools/ffplay: do not write out of rdft visualization texture 2021-03-10 20:01:03 +01:00
ffprobe.c fftools/ffprobe: use av_packet_alloc() to allocate packets 2021-03-17 15:19:38 -03:00
Makefile ffmpeg: remove superfluous custom cuvid hwaccel 2020-03-03 18:11:28 -03:00