avcodec/osq: avoid undefined negation
authorMichael Niedermayer <[email protected]>
Tue, 4 Feb 2025 02:58:45 +0000 (03:58 +0100)
committerMichael Niedermayer <[email protected]>
Mon, 4 Aug 2025 16:51:24 +0000 (18:51 +0200)
Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: 390646659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-5040277374435328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
(cherry picked from commit c6a889f3e09249d2a643a6beb7d44a8e42ea3541)
Signed-off-by: Michael Niedermayer <[email protected]>
libavcodec/osq.c

index 17dec52fcc30b12050f0f1ebf35d35711485ce3b..99a035c5c53e2c7fef7ba828c6b2ce92d1653895 100644 (file)
@@ -189,7 +189,7 @@ static uint32_t get_urice(GetBitContext *gb, int k)
 
 static int32_t get_srice(GetBitContext *gb, int x)
 {
-    int32_t y = get_urice(gb, x);
+    uint32_t y = get_urice(gb, x);
     return get_bits1(gb) ? -y : y;
 }