mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 04:17:05 +00:00
smacker: use meaningful error codes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
29c3ebf56e
commit
547b8aeed4
@ -110,7 +110,7 @@ static int smacker_read_header(AVFormatContext *s)
|
|||||||
/* read and check header */
|
/* read and check header */
|
||||||
smk->magic = avio_rl32(pb);
|
smk->magic = avio_rl32(pb);
|
||||||
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
|
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
smk->width = avio_rl32(pb);
|
smk->width = avio_rl32(pb);
|
||||||
smk->height = avio_rl32(pb);
|
smk->height = avio_rl32(pb);
|
||||||
smk->frames = avio_rl32(pb);
|
smk->frames = avio_rl32(pb);
|
||||||
@ -124,7 +124,7 @@ static int smacker_read_header(AVFormatContext *s)
|
|||||||
|
|
||||||
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
|
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
|
||||||
av_log(s, AV_LOG_ERROR, "treesize too large\n");
|
av_log(s, AV_LOG_ERROR, "treesize too large\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME remove extradata "rebuilding"
|
//FIXME remove extradata "rebuilding"
|
||||||
@ -140,7 +140,7 @@ static int smacker_read_header(AVFormatContext *s)
|
|||||||
/* setup data */
|
/* setup data */
|
||||||
if(smk->frames > 0xFFFFFF) {
|
if(smk->frames > 0xFFFFFF) {
|
||||||
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
|
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
smk->frm_size = av_malloc(smk->frames * 4);
|
smk->frm_size = av_malloc(smk->frames * 4);
|
||||||
smk->frm_flags = av_malloc(smk->frames);
|
smk->frm_flags = av_malloc(smk->frames);
|
||||||
@ -158,7 +158,7 @@ static int smacker_read_header(AVFormatContext *s)
|
|||||||
/* init video codec */
|
/* init video codec */
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return -1;
|
return AVERROR(ENOMEM);
|
||||||
smk->videoindex = st->index;
|
smk->videoindex = st->index;
|
||||||
st->codec->width = smk->width;
|
st->codec->width = smk->width;
|
||||||
st->codec->height = smk->height;
|
st->codec->height = smk->height;
|
||||||
@ -216,7 +216,7 @@ static int smacker_read_header(AVFormatContext *s)
|
|||||||
av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
|
av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
|
||||||
av_free(smk->frm_size);
|
av_free(smk->frm_size);
|
||||||
av_free(smk->frm_flags);
|
av_free(smk->frm_flags);
|
||||||
return -1;
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
|
ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
|
||||||
if(ret != st->codec->extradata_size - 16){
|
if(ret != st->codec->extradata_size - 16){
|
||||||
|
Loading…
Reference in New Issue
Block a user