[FFmpeg-devel] [PATCH 3/3] ffmdec: change type of len to ptrdiff_t

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sat Jan 2 16:52:25 CET 2016


It is used to store the difference between pointers, so ptrdiff_t is the
correct type.

This prevents potential overflows.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavformat/ffmdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 3162354..f4f8144 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -36,7 +36,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
 {
     FFMContext *ffm = s->priv_data;
     int64_t pos, avail_size;
-    int len;
+    ptrdiff_t len;
 
     len = ffm->packet_end - ffm->packet_ptr;
     if (size <= len)
@@ -87,7 +87,8 @@ static int ffm_read_data(AVFormatContext *s,
 {
     FFMContext *ffm = s->priv_data;
     AVIOContext *pb = s->pb;
-    int len, fill_size, size1, frame_offset, id;
+    int fill_size, size1, frame_offset, id;
+    ptrdiff_t len;
     int64_t last_pos = -1;
 
     size1 = size;
-- 
2.6.4



More information about the ffmpeg-devel mailing list