diff mbox series

[FFmpeg-devel] avformat/assenc: Fix potential NULL + 1

Message ID AS8P250MB07442F1C47B0066F448497648FBE9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 43991dbd0557cd4142e90d0d9698c7678cee60b6
Headers show
Series [FFmpeg-devel] avformat/assenc: Fix potential NULL + 1 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 14, 2023, 3:10 a.m. UTC
Incrementing a NULL pointer is undefined behaviour,
yet this is what would happen in case trailer were NULL
before the check.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/assenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index 85a1e53371..a75f458023 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -63,8 +63,8 @@  static int write_header(AVFormatContext *s)
         if (trailer)
             trailer = strstr(trailer, "\n");
 
-        if (trailer++) {
-            header_size = (trailer - par->extradata);
+        if (trailer) {
+            header_size = (++trailer - par->extradata);
             ass->trailer_size = par->extradata_size - header_size;
             if (ass->trailer_size)
                 ass->trailer = trailer;