]> git.sesse.net Git - ffmpeg/commitdiff
sgi: Correctly propagate meaningful error values
authorVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 23 Nov 2015 23:56:09 +0000 (18:56 -0500)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 24 Nov 2015 14:05:01 +0000 (09:05 -0500)
libavcodec/sgidec.c
libavcodec/sgienc.c

index c827ff555974ef9d03c5f78da36443f4ccdc360c..6f93a3059e16235e1358382a0a751e78a427b9d5 100644 (file)
@@ -229,13 +229,13 @@ static int decode_frame(AVCodecContext *avctx,
 
     if (s->bytes_per_channel != 1 && s->bytes_per_channel != 2) {
         av_log(avctx, AV_LOG_ERROR, "wrong channel number\n");
-        return -1;
+        return AVERROR(EINVAL);
     }
 
     /* Check for supported image dimensions. */
     if (dimension != 2 && dimension != 3) {
         av_log(avctx, AV_LOG_ERROR, "wrong dimension number\n");
-        return -1;
+        return AVERROR(EINVAL);
     }
 
     if (s->depth == SGI_GRAYSCALE) {
@@ -246,16 +246,17 @@ static int decode_frame(AVCodecContext *avctx,
         avctx->pix_fmt = s->bytes_per_channel == 2 ? AV_PIX_FMT_RGBA64BE : AV_PIX_FMT_RGBA;
     } else {
         av_log(avctx, AV_LOG_ERROR, "wrong picture format\n");
-        return -1;
+        return AVERROR(EINVAL);
     }
 
     ret = ff_set_dimensions(avctx, s->width, s->height);
     if (ret < 0)
         return ret;
 
-    if (ff_get_buffer(avctx, p, 0) < 0) {
+    ret = ff_get_buffer(avctx, p, 0);
+    if (ret < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed.\n");
-        return -1;
+        return ret;
     }
 
     p->pict_type = AV_PICTURE_TYPE_I;
index c5e66cd087411a350e3e182fcd2a135e5661060c..2da4f51d444e2f3ca4d4e65129c162a0ff60233a 100644 (file)
@@ -193,7 +193,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
         /* Make an intermediate consecutive buffer. */
         if (!(encode_buf = av_malloc(width * bytes_per_channel)))
-            return -1;
+            return AVERROR(ENOMEM);
 
         for (z = 0; z < depth; z++) {
             in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
@@ -208,7 +208,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
                                         bytes_per_channel);
                 if (length < 1) {
                     av_free(encode_buf);
-                    return -1;
+                    return AVERROR_INVALIDDATA;
                 }
 
                 bytestream2_put_be32(&tablen_pcb, length);