Commit c7ea88c5 authored by bcoudurier's avatar bcoudurier

fail if extradata cannot be allocated

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@12206 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent dd36d2a1
...@@ -292,14 +292,14 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) ...@@ -292,14 +292,14 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
if (tag == MP4DecSpecificDescrTag) { if (tag == MP4DecSpecificDescrTag) {
dprintf(c->fc, "Specific MPEG4 header len=%d\n", len); dprintf(c->fc, "Specific MPEG4 header len=%d\n", len);
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) { if (!st->codec->extradata)
return AVERROR(ENOMEM);
get_buffer(pb, st->codec->extradata, len); get_buffer(pb, st->codec->extradata, len);
st->codec->extradata_size = len; st->codec->extradata_size = len;
/* from mplayer */ /* from mplayer */
if ((*st->codec->extradata >> 3) == 29) { if ((*st->codec->extradata >> 3) == 29) {
st->codec->codec_id = CODEC_ID_MP3ON4; st->codec->codec_id = CODEC_ID_MP3ON4;
} }
}
} }
} }
return 0; return 0;
...@@ -420,16 +420,13 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) ...@@ -420,16 +420,13 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
// currently SVQ3 decoder expect full STSD header - so let's fake it // currently SVQ3 decoder expect full STSD header - so let's fake it
// this should be fixed and just SMI header should be passed // this should be fixed and just SMI header should be passed
av_free(st->codec->extradata); av_free(st->codec->extradata);
st->codec->extradata_size = 0x5a + atom.size; st->codec->extradata = av_mallocz(atom.size + 0x5a + FF_INPUT_BUFFER_PADDING_SIZE);
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata)
return AVERROR(ENOMEM);
if (st->codec->extradata) { st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake memcpy(st->codec->extradata, "SVQ3", 4); // fake
get_buffer(pb, st->codec->extradata + 0x5a, atom.size); get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
dprintf(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a); dprintf(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
} else
url_fskip(pb, atom.size);
return 0; return 0;
} }
...@@ -483,13 +480,11 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) ...@@ -483,13 +480,11 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
if (st->codec->codec_id == CODEC_ID_QDM2) { if (st->codec->codec_id == CODEC_ID_QDM2) {
// pass all frma atom to codec, needed at least for QDM2 // pass all frma atom to codec, needed at least for QDM2
av_free(st->codec->extradata); av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size; st->codec->extradata_size = atom.size;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, atom.size);
if (st->codec->extradata) {
get_buffer(pb, st->codec->extradata, atom.size);
} else
url_fskip(pb, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */ } else if (atom.size > 8) { /* to read frma, esds atoms */
if (mov_read_default(c, pb, atom) < 0) if (mov_read_default(c, pb, atom) < 0)
return -1; return -1;
...@@ -510,15 +505,11 @@ static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) ...@@ -510,15 +505,11 @@ static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
return -1; return -1;
av_free(st->codec->extradata); av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size; st->codec->extradata_size = atom.size;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, atom.size);
if (st->codec->extradata) {
get_buffer(pb, st->codec->extradata, atom.size);
} else
url_fskip(pb, atom.size);
return 0; return 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