Commit 115a5730 authored by Martin Storsjö's avatar Martin Storsjö

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: 's avatarMartin Storsjö <martin@martin.st>
parent c41b9842
...@@ -503,8 +503,15 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -503,8 +503,15 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
v->pb.seekable = 0; v->pb.seekable = 0;
ret = av_probe_input_buffer(&v->pb, &in_fmt, v->segments[0]->url, ret = av_probe_input_buffer(&v->pb, &in_fmt, v->segments[0]->url,
NULL, 0, 0); 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; goto fail;
}
v->ctx->pb = &v->pb; v->ctx->pb = &v->pb;
ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL); ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment