[FFmpeg-cvslog] smacker: return meaningful error codes on failure

Sean McGovern git at videolan.org
Sat Nov 11 20:22:41 EET 2017


ffmpeg | branch: master | Sean McGovern <gseanmcg at gmail.com> | Sun Sep 24 12:57:54 2017 +0200| [9e361022782514d4d4ce97b9c9d5a7863a2de519] | committer: Sean McGovern

smacker: return meaningful error codes on failure

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e361022782514d4d4ce97b9c9d5a7863a2de519
---

 libavformat/smacker.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index eb4b63fdad..56c909bc06 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -112,7 +112,7 @@ static int smacker_read_header(AVFormatContext *s)
     /* read and check header */
     smk->magic = avio_rl32(pb);
     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->height = avio_rl32(pb);
     smk->frames = avio_rl32(pb);
@@ -126,7 +126,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)
         av_log(s, AV_LOG_ERROR, "treesize too large\n");
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
 
 //FIXME remove extradata "rebuilding"
@@ -142,7 +142,7 @@ static int smacker_read_header(AVFormatContext *s)
     /* setup data */
     if(smk->frames > 0xFFFFFF) {
         av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames);
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
     smk->frm_size = av_malloc(smk->frames * 4);
     smk->frm_flags = av_malloc(smk->frames);
@@ -160,7 +160,7 @@ static int smacker_read_header(AVFormatContext *s)
     /* init video codec */
     st = avformat_new_stream(s, NULL);
     if (!st)
-        return -1;
+        return AVERROR(ENOMEM);
     smk->videoindex = st->index;
     st->codecpar->width = smk->width;
     st->codecpar->height = smk->height;
@@ -221,7 +221,7 @@ static int smacker_read_header(AVFormatContext *s)
                smk->treesize + 16);
         av_free(smk->frm_size);
         av_free(smk->frm_flags);
-        return -1;
+        return AVERROR(ENOMEM);
     }
     ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_size - 16);
     if(ret != st->codecpar->extradata_size - 16){



More information about the ffmpeg-cvslog mailing list