mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
oggparsevorbis: check allocations
Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
9c15ef35d4
commit
ed9245dba8
@ -172,15 +172,17 @@ struct oggvorbis_private {
|
|||||||
int final_duration;
|
int final_duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int fixup_vorbis_headers(AVFormatContext *as,
|
static int fixup_vorbis_headers(AVFormatContext *as,
|
||||||
struct oggvorbis_private *priv,
|
struct oggvorbis_private *priv,
|
||||||
uint8_t **buf)
|
uint8_t **buf)
|
||||||
{
|
{
|
||||||
int i, offset, len, err;
|
int i, offset, len, err;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
len = priv->len[0] + priv->len[1] + priv->len[2];
|
len = priv->len[0] + priv->len[1] + priv->len[2];
|
||||||
ptr = *buf = av_mallocz(len + len / 255 + 64);
|
ptr = *buf = av_mallocz(len + len / 255 + 64);
|
||||||
|
if (!ptr)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ptr[0] = 2;
|
ptr[0] = 2;
|
||||||
offset = 1;
|
offset = 1;
|
||||||
@ -236,6 +238,8 @@ static int vorbis_header(AVFormatContext *s, int idx)
|
|||||||
|
|
||||||
priv->len[pkt_type >> 1] = os->psize;
|
priv->len[pkt_type >> 1] = os->psize;
|
||||||
priv->packet[pkt_type >> 1] = av_mallocz(os->psize);
|
priv->packet[pkt_type >> 1] = av_mallocz(os->psize);
|
||||||
|
if (!priv->packet[pkt_type >> 1])
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
memcpy(priv->packet[pkt_type >> 1], os->buf + os->pstart, os->psize);
|
memcpy(priv->packet[pkt_type >> 1], os->buf + os->pstart, os->psize);
|
||||||
if (os->buf[os->pstart] == 1) {
|
if (os->buf[os->pstart] == 1) {
|
||||||
const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */
|
const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */
|
||||||
|
Loading…
Reference in New Issue
Block a user