mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 07:35:57 -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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_XCODE, "Cannot open encoder (%s): %s\n", codec_desc->name, err2str(ret));
|
DPRINTF(E_LOG, L_XCODE, "Cannot open encoder (%s): %s\n", codec_desc->name, err2str(ret));
|
||||||
avcodec_free_context(&s->codec);
|
goto error;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the codec parameters we just set to the stream, so the muxer knows them
|
// 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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_XCODE, "Cannot copy stream parameters (%s): %s\n", codec_desc->name, err2str(ret));
|
DPRINTF(E_LOG, L_XCODE, "Cannot copy stream parameters (%s): %s\n", codec_desc->name, err2str(ret));
|
||||||
avcodec_free_context(&s->codec);
|
goto error;
|
||||||
return -1;
|
}
|
||||||
|
|
||||||
|
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;
|
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