From 43991dbd0557cd4142e90d0d9698c7678cee60b6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 14 Mar 2023 04:03:19 +0100 Subject: [PATCH] avformat/assenc: Fix potential NULL + 1 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 --- libavformat/assenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/assenc.c b/libavformat/assenc.c index 6ecfb04517..62ea0745a4 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;