[FFmpeg-cvslog] shorten: use the unsigned type where needed

Luca Barbato git at videolan.org
Sun Oct 6 19:06:11 CEST 2013


ffmpeg | branch: release/0.7 | Luca Barbato <lu_zero at gentoo.org> | Tue Mar  5 17:12:35 2013 +0100| [6d4d186e9e9fcba9f9058691ab00eade028fceff] | committer: Reinhard Tartler

shorten: use the unsigned type where needed

get_uint returns an unsigned value, use an unsigned to store
blocksize to make sure the comparison logic is correct and report
correctly the error for the channel count not supported.

CC: libav-stable at libav.org

(cherry picked from commit 5cf7c72757779a740e897a97710aac044fe5258c)
(cherry picked from commit 88089eecfd7e604d40d078b4f4206c647cb2e2b4)
(cherry picked from commit f42d03746afe491dd02bb6372961e85e78299864)

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
Signed-off-by: Reinhard Tartler <siretart at tauware.de>

Conflicts:
	libavcodec/shorten.c

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

 libavcodec/shorten.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index b5473dd..3ca2835 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -78,7 +78,7 @@ typedef struct ShortenContext {
     GetBitContext gb;
 
     int min_framesize, max_framesize;
-    int channels;
+    unsigned channels;
 
     int32_t *decoded[MAX_CHANNELS];
     int32_t *decoded_base[MAX_CHANNELS];
@@ -342,6 +342,10 @@ static int shorten_decode_frame(AVCodecContext *avctx,
         s->internal_ftype = get_uint(s, TYPESIZE);
 
         s->channels = get_uint(s, CHANSIZE);
+        if (!s->channels) {
+            av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n");
+            return AVERROR_INVALIDDATA;
+        }
         if (s->channels <= 0 || s->channels > MAX_CHANNELS) {
             av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
             s->channels = 0;
@@ -501,7 +505,7 @@ static int shorten_decode_frame(AVCodecContext *avctx,
                 s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
                 break;
             case FN_BLOCKSIZE: {
-                int blocksize = get_uint(s, av_log2(s->blocksize));
+                unsigned blocksize = get_uint(s, av_log2(s->blocksize));
                 if (blocksize > s->blocksize) {
                     av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n");
                     return AVERROR_PATCHWELCOME;



More information about the ffmpeg-cvslog mailing list