mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
mpegps: Handle buffer exhaustion when reading packets.
This commit is contained in:
parent
0c378ea1f7
commit
9fba8ebe0a
@ -418,7 +418,7 @@ static int mpegps_read_packet(AVFormatContext *s,
|
|||||||
{
|
{
|
||||||
MpegDemuxContext *m = s->priv_data;
|
MpegDemuxContext *m = s->priv_data;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
int len, startcode, i, es_type;
|
int len, startcode, i, es_type, ret;
|
||||||
enum CodecID codec_id = CODEC_ID_NONE;
|
enum CodecID codec_id = CODEC_ID_NONE;
|
||||||
enum AVMediaType type;
|
enum AVMediaType type;
|
||||||
int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
|
int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
|
||||||
@ -562,7 +562,13 @@ static int mpegps_read_packet(AVFormatContext *s,
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
av_new_packet(pkt, len);
|
av_new_packet(pkt, len);
|
||||||
avio_read(s->pb, pkt->data, pkt->size);
|
ret = avio_read(s->pb, pkt->data, pkt->size);
|
||||||
|
if (ret < 0) {
|
||||||
|
pkt->size = 0;
|
||||||
|
} else if (ret < pkt->size) {
|
||||||
|
pkt->size = ret;
|
||||||
|
memset(pkt->data + ret, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
}
|
||||||
pkt->pts = pts;
|
pkt->pts = pts;
|
||||||
pkt->dts = dts;
|
pkt->dts = dts;
|
||||||
pkt->pos = dummy_pos;
|
pkt->pos = dummy_pos;
|
||||||
@ -571,7 +577,7 @@ static int mpegps_read_packet(AVFormatContext *s,
|
|||||||
pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0,
|
pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0,
|
||||||
pkt->size);
|
pkt->size);
|
||||||
|
|
||||||
return 0;
|
return (ret < 0) ? ret : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,
|
static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user