This is undefined behaviour in C, so use data = len ? data + len : data
instead if data += len. GCC optimizes the branch away in this case;
Clang unfortunately doesn't.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com>
---
Checking for len != 0 instead of > 0 allows the compiler to optimize the
branch away; maybe future versions of Clang (I used 11) will do so, too. 

 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3e955b85bc..cea6d4ca92 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1426,7 +1426,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         pkt->pts = pkt->dts = AV_NOPTS_VALUE;
         pkt->pos = -1;
         /* increment read pointer */
-        data += len;
+        data  = len ? data + len : data;
         size -= len;
 
         got_output = !!out_pkt.size;
-- 
2.27.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to