[FFmpeg-devel] [PATCH 01/25] avformat/matroskaenc: Fix potential overflow

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Jan 17 00:49:02 EET 2022


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/matroskaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 41b2df7dbf..1dde12a7d9 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val)
 static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val)
 {
     int i, bytes = 1;
-    uint64_t tmp = 2*(val < 0 ? val^-1 : val);
+    uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val);
 
     while (tmp >>= 8)
         bytes++;
-- 
2.32.0



More information about the ffmpeg-devel mailing list