[FFmpeg-devel] [PATCH]Fix memleak if decoder init fails
Michael Niedermayer
michaelni at gmx.at
Thu Mar 7 12:53:13 CET 2013
On Thu, Mar 07, 2013 at 10:38:42AM +0100, Carl Eugen Hoyos wrote:
> On Saturday 02 March 2013 10:02:39 pm Carl Eugen Hoyos wrote:
>
> > Both attached patches fix the memleak that happens if the decoder
> > initialisation fails, see ticket #1244 for an example.
>
> New patch attached that probably catches a few more cases.
>
> Please comment, Carl Eugen
> ffmpeg.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
> 7d23fe5f1602bdde72583ef56923dbda109a2b70 patchtranscodeleak3.diff
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 229a896..3f87cfc 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -2542,6 +2542,16 @@ static int transcode_init(void)
> }
>
> if (ret) {
> + for (i = 0; i < nb_output_streams; i++) {
> + ost = output_streams[i];
> + if (ost && ost->st && ost->st->codec)
> + avcodec_close(ost->st->codec);
> + }
> + for (i = 0; i < nb_input_streams; i++) {
> + ist = input_streams[i];
> + if (ist && ist->st && ist->st->codec)
> + avcodec_close(ist->st->codec);
> + }
This can probably call close on contexts that have been returned by
a failed open.
Iam not sure this is safe ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130307/0640b1dd/attachment.asc>
More information about the ffmpeg-devel
mailing list