[FFmpeg-devel] [PATCH]Fix memleak if decoder init fails
Carl Eugen Hoyos
cehoyos at ag.or.at
Thu Mar 7 10:38:42 CET 2013
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
-------------- next part --------------
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);
+ }
av_log(NULL, AV_LOG_ERROR, "%s\n", error);
return ret;
}
More information about the ffmpeg-devel
mailing list