diff mbox

[FFmpeg-devel,1/5] avformat/mpeg: Don't free unintialized pointer

Message ID 20191022131645.8394-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 262eef6b899ca39f80296e6eb701e895549d8a83
Headers show

Commit Message

Andreas Rheinhardt Oct. 22, 2019, 1:16 p.m. UTC
In order to fix a potential memleak upon failure, 0b8956b2 made sure that
a buffer given by a pointer was freed upon error. But this pointer was
only initialized upon use and in several cases (Clang gives no fewer
than 13 -Wsometimes-uninitialized warnings) this meant that an
uninitialized pointer was used to free a buffer. So initialize the
pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Was 0b8956b2 ever sent to the ML before it got pushed? I couldn't find
it. And what does CID mean?

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

Comments

James Almer Oct. 24, 2019, 6:52 p.m. UTC | #1
On 10/22/2019 10:16 AM, Andreas Rheinhardt wrote:
> In order to fix a potential memleak upon failure, 0b8956b2 made sure that
> a buffer given by a pointer was freed upon error. But this pointer was
> only initialized upon use and in several cases (Clang gives no fewer
> than 13 -Wsometimes-uninitialized warnings) this meant that an
> uninitialized pointer was used to free a buffer. So initialize the
> pointer.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> Was 0b8956b2 ever sent to the ML before it got pushed? I couldn't find
> it. And what does CID mean?
> 
>  libavformat/mpeg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index c33401f1a0..ebc064931a 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -720,7 +720,7 @@ static int vobsub_read_header(AVFormatContext *s)
>      int i, ret = 0, header_parsed = 0, langidx = 0;
>      MpegDemuxContext *vobsub = s->priv_data;
>      size_t fname_len;
> -    char *header_str;
> +    char *header_str = NULL;
>      AVBPrint header;
>      int64_t delay = 0;
>      AVStream *st = NULL;

Applied, thanks.
diff mbox

Patch

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index c33401f1a0..ebc064931a 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -720,7 +720,7 @@  static int vobsub_read_header(AVFormatContext *s)
     int i, ret = 0, header_parsed = 0, langidx = 0;
     MpegDemuxContext *vobsub = s->priv_data;
     size_t fname_len;
-    char *header_str;
+    char *header_str = NULL;
     AVBPrint header;
     int64_t delay = 0;
     AVStream *st = NULL;