ffmpeg/fftools
Andreas Rheinhardt 371692641e
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-23 04:32:15 +01:00
..
cmdutils.c fftools/cmdutils: Add protective () to FLAGS 2024-06-13 19:58:01 +02:00
cmdutils.h fftools/cmdutils: split common option handlers into their own file 2022-03-22 18:49:43 +01:00
ffmpeg.c fftools/ffmpeg: Check read() for failure 2024-07-21 18:55:33 +02:00
ffmpeg.h ffmpeg: add option -isync 2022-07-14 15:49:10 +05:30
ffmpeg_filter.c ffmpeg: convert to new channel layout-API 2022-03-15 09:42:46 -03:00
ffmpeg_hw.c ffmpeg_hw: make hardware selection for filters more user friendly 2021-09-12 13:33:50 -03:00
ffmpeg_mux.c ffmpeg: add option fps_mode 2022-06-11 09:47:27 +05:30
ffmpeg_opt.c fftools/ffmpeg_mux_init: Fix double-free on error 2025-11-23 04:32:15 +01:00
ffplay.c fftools/ffplay: Check return of swr_alloc_set_opts2() 2024-06-13 11:22:08 +02:00
ffprobe.c fftools/ffprobe: support 2D arrays in print_list_fmt() 2023-12-06 16:12:39 -03:00
fopen_utf8.h fftools/fopen_utf8: support long paths on Windows for fftools 2022-06-19 01:38:23 +03:00
Makefile fftools/ffmpeg: move some muxing-related code into a separate file 2022-04-13 12:07:54 +02:00
opt_common.c tools/opt_common: Check for malloc failure 2024-06-13 11:22:08 +02:00
opt_common.h fftools/cmdutils: split common option handlers into their own file 2022-03-22 18:49:43 +01:00