avcodec/h264_cavlc: Fix undefined behavior on qscale overflow
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 22 Apr 2017 19:59:29 +0000 (21:59 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 22 Apr 2017 20:26:00 +0000 (22:26 +0200)
Fixes: 1214/clusterfuzz-testcase-minimized-6130606599569408

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/h264_cavlc.c

index 069b521..72dfaaa 100644 (file)
@@ -1112,7 +1112,7 @@ decode_intra_mb:
 
         dquant= get_se_golomb(&sl->gb);
 
-        sl->qscale += dquant;
+        sl->qscale += (unsigned)dquant;
 
         if (((unsigned)sl->qscale) > max_qp){
             if (sl->qscale < 0) sl->qscale += max_qp + 1;