• Andreas Rheinhardt's avatar
    fftools/ffmpeg_mux_init: Fix double-free on error · ced5c5fd
    Andreas Rheinhardt authored
    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 83ace80b.
    
    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: 's avatarMarth64 <marth64@proxyid.net>
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
    ced5c5fd
ffmpeg_mux_init.c 103 KB