diff options
author | Martin Storsjö <martin@martin.st> | 2011-12-14 20:34:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-03 18:12:33 +0100 |
commit | bf9af661b8647c9ecbfe75e24b0aa3497c4ddd73 (patch) | |
tree | 84ace5497b6119fcd06b61b82eed90d67df5ea68 /libavformat | |
parent | 63d5fa55fe1aad9eb64c91c41e11c581808085c4 (diff) | |
download | ffmpeg-bf9af661b8647c9ecbfe75e24b0aa3497c4ddd73.tar.gz |
applehttp: Properly clean up if unable to probe a segment
This avoids a segfault if the probe function wasn't able to
determine the format.
The bug was found by Panagiotis H.M. Issaris.
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 115a57302a7d6661426304bec3a5bc72d0edf4b0)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/applehttp.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 18b19d81eb..d530db4952 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -503,8 +503,15 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) v->pb.seekable = 0; ret = av_probe_input_buffer(&v->pb, &in_fmt, v->segments[0]->url, NULL, 0, 0); - if (ret < 0) + if (ret < 0) { + /* Free the ctx - it isn't initialized properly at this point, + * so avformat_close_input shouldn't be called. If + * avformat_open_input fails below, it frees and zeros the + * context, so it doesn't need any special treatment like this. */ + avformat_free_context(v->ctx); + v->ctx = NULL; goto fail; + } v->ctx->pb = &v->pb; ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL); if (ret < 0) |