summaryrefslogtreecommitdiffstats
path: root/libavcodec/shorten.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-03-05 17:12:35 +0100
committerLuca Barbato <lu_zero@gentoo.org>2013-03-06 01:04:02 +0100
commit5cf7c72757779a740e897a97710aac044fe5258c (patch)
treed0744fcdcaa01041bd8c9508a04ad63e8b0901aa /libavcodec/shorten.c
parent4c364eb2b856fc33cf7b42f7c7b979e69fde5f3a (diff)
downloadffmpeg-streaming-5cf7c72757779a740e897a97710aac044fe5258c.zip
ffmpeg-streaming-5cf7c72757779a740e897a97710aac044fe5258c.tar.gz
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.
Diffstat (limited to 'libavcodec/shorten.c')
-rw-r--r--libavcodec/shorten.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index dd35516..d6c9386 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -83,7 +83,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];
@@ -339,7 +339,11 @@ static int read_header(ShortenContext *s)
s->internal_ftype = get_uint(s, TYPESIZE);
s->channels = get_uint(s, CHANSIZE);
- if (s->channels <= 0 || s->channels > MAX_CHANNELS) {
+ if (!s->channels) {
+ av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (s->channels > MAX_CHANNELS) {
av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
s->channels = 0;
return AVERROR_INVALIDDATA;
@@ -348,7 +352,8 @@ static int read_header(ShortenContext *s)
/* get blocksize if version > 0 */
if (s->version > 0) {
- int skip_bytes, blocksize;
+ int skip_bytes;
+ unsigned blocksize;
blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE));
if (!blocksize || blocksize > MAX_BLOCKSIZE) {
@@ -501,7 +506,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
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");
OpenPOWER on IntegriCloud