mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
[xcode] Protect against memleak if future ffmpeg doesn't free options
Can happen if ffmpeg doesn't recognize all the options
This commit is contained in:
parent
aa2512837e
commit
8b6336b91d
@ -522,8 +522,7 @@ stream_add(struct encode_ctx *ctx, struct stream_ctx *s, enum AVCodecID codec_id
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_XCODE, "Cannot open encoder (%s): %s\n", codec_desc->name, err2str(ret));
|
||||
avcodec_free_context(&s->codec);
|
||||
return -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Copy the codec parameters we just set to the stream, so the muxer knows them
|
||||
@ -531,11 +530,24 @@ stream_add(struct encode_ctx *ctx, struct stream_ctx *s, enum AVCodecID codec_id
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_XCODE, "Cannot copy stream parameters (%s): %s\n", codec_desc->name, err2str(ret));
|
||||
avcodec_free_context(&s->codec);
|
||||
return -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (options)
|
||||
{
|
||||
DPRINTF(E_WARN, L_XCODE, "Encoder %s didn't recognize all options given to avcodec_open2\n", codec_desc->name);
|
||||
av_dict_free(&options);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (s->codec)
|
||||
avcodec_free_context(&s->codec);
|
||||
if (options)
|
||||
av_dict_free(&options);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user