Merge commit 'f6c82b34a320f105af266997f5951cbe7dfc8a05' into release/2.4
* commit 'f6c82b34a320f105af266997f5951cbe7dfc8a05': segment: Fix the failure paths Conflicts: libavformat/segment.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -561,6 +561,13 @@ static int select_reference_stream(AVFormatContext *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void seg_free_context(SegmentContext *seg)
|
||||||
|
{
|
||||||
|
avio_closep(&seg->list_pb);
|
||||||
|
avformat_free_context(seg->avf);
|
||||||
|
seg->avf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int seg_write_header(AVFormatContext *s)
|
static int seg_write_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
SegmentContext *seg = s->priv_data;
|
SegmentContext *seg = s->priv_data;
|
||||||
@@ -692,12 +699,9 @@ static int seg_write_header(AVFormatContext *s)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
av_dict_free(&options);
|
av_dict_free(&options);
|
||||||
if (ret) {
|
if (ret < 0)
|
||||||
if (seg->list)
|
seg_free_context(seg);
|
||||||
avio_close(seg->list_pb);
|
|
||||||
if (seg->avf)
|
|
||||||
avformat_free_context(seg->avf);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,6 +716,9 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
int64_t usecs;
|
int64_t usecs;
|
||||||
int64_t wrapped_val;
|
int64_t wrapped_val;
|
||||||
|
|
||||||
|
if (!seg->avf)
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
if (seg->times) {
|
if (seg->times) {
|
||||||
end_pts = seg->segment_count < seg->nb_times ?
|
end_pts = seg->segment_count < seg->nb_times ?
|
||||||
seg->times[seg->segment_count] : INT64_MAX;
|
seg->times[seg->segment_count] : INT64_MAX;
|
||||||
@@ -806,6 +813,9 @@ fail:
|
|||||||
seg->segment_frame_count++;
|
seg->segment_frame_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
seg_free_context(seg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,8 +824,11 @@ static int seg_write_trailer(struct AVFormatContext *s)
|
|||||||
SegmentContext *seg = s->priv_data;
|
SegmentContext *seg = s->priv_data;
|
||||||
AVFormatContext *oc = seg->avf;
|
AVFormatContext *oc = seg->avf;
|
||||||
SegmentListEntry *cur, *next;
|
SegmentListEntry *cur, *next;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!oc)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
int ret;
|
|
||||||
if (!seg->write_header_trailer) {
|
if (!seg->write_header_trailer) {
|
||||||
if ((ret = segment_end(s, 0, 1)) < 0)
|
if ((ret = segment_end(s, 0, 1)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Reference in New Issue
Block a user