diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-22 12:39:48 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-22 12:43:45 +0100 |
commit | bdf831859f0df264de4a23d3ed80684b6b1324b1 (patch) | |
tree | 9698a0a7aed4197de54fefad52ea9529b78d593f /libavcodec/truemotion1.c | |
parent | 4b3b702f9256e8184cb3883460ba3805d9f2ca45 (diff) | |
parent | c918e08b9cc9ce8d06159c51da55ec5ab018039a (diff) | |
download | ffmpeg-bdf831859f0df264de4a23d3ed80684b6b1324b1.tar.gz |
Merge commit 'c918e08b9cc9ce8d06159c51da55ec5ab018039a'
* commit 'c918e08b9cc9ce8d06159c51da55ec5ab018039a':
truemotion1: make sure index does not go out of bounds
See: fd4c1c0b70b5a06dd572d7e27799a2f4c3d9b984
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/truemotion1.c')
-rw-r--r-- | libavcodec/truemotion1.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 6e7d305aa4..6528a1f391 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -519,11 +519,16 @@ hres,vres,i,i%vres (0 < i < 4) index = s->index_stream[index_stream_index++] * 4; \ } +#define INC_INDEX \ +do { \ + if (index >= 1023) { \ + av_log(s->avctx, AV_LOG_ERROR, "Invalid index value.\n"); \ + return; \ + } \ + index++; \ +} while (0) + #define APPLY_C_PREDICTOR() \ - if(index > 1023){\ - av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ - return; \ - }\ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -535,16 +540,12 @@ hres,vres,i,i%vres (0 < i < 4) if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ - index++; \ + INC_INDEX; \ } \ } else \ - index++; + INC_INDEX; #define APPLY_C_PREDICTOR_24() \ - if(index > 1023){\ - av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ - return; \ - }\ predictor_pair = s->c_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -556,17 +557,13 @@ hres,vres,i,i%vres (0 < i < 4) if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ - index++; \ + INC_INDEX; \ } \ } else \ - index++; + INC_INDEX; #define APPLY_Y_PREDICTOR() \ - if(index > 1023){\ - av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ - return; \ - }\ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -578,16 +575,12 @@ hres,vres,i,i%vres (0 < i < 4) if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ - index++; \ + INC_INDEX; \ } \ } else \ - index++; + INC_INDEX; #define APPLY_Y_PREDICTOR_24() \ - if(index > 1023){\ - av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \ - return; \ - }\ predictor_pair = s->y_predictor_table[index]; \ horiz_pred += (predictor_pair >> 1); \ if (predictor_pair & 1) { \ @@ -599,10 +592,10 @@ hres,vres,i,i%vres (0 < i < 4) if (predictor_pair & 1) \ GET_NEXT_INDEX() \ else \ - index++; \ + INC_INDEX; \ } \ } else \ - index++; + INC_INDEX; #define OUTPUT_PIXEL_PAIR() \ *current_pixel_pair = *vert_pred + horiz_pred; \ |