[vlc-devel] [PATCH v1] ogg codecs: use checked realloc() instead of xrealloc()
Michael Tänzer
neo at nhng.de
Fri Mar 4 21:45:44 CET 2016
---
modules/codec/daala.c | 10 ++++++++--
modules/codec/kate.c | 9 +++++++--
modules/codec/oggspots.c | 8 ++++++--
modules/codec/speex.c | 9 +++++++--
modules/codec/theora.c | 11 +++++++++--
modules/codec/vorbis.c | 9 +++++++--
6 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/modules/codec/daala.c b/modules/codec/daala.c
index ae790dd..fb79ed7 100644
--- a/modules/codec/daala.c
+++ b/modules/codec/daala.c
@@ -380,9 +380,15 @@ static int ProcessHeaders( decoder_t *p_dec )
}
else
{
+ void* p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra );
+ if( unlikely( p_extra == NULL ) )
+ {
+ ret = VLC_ENOMEM;
+ goto cleanup;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index 64befc6..fe2ec96 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -592,9 +592,14 @@ static int ProcessHeaders( decoder_t *p_dec )
#ifdef ENABLE_PACKETIZER
else
{
+ void* p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra );
+ if( unlikely( p_extra == NULL ) )
+ {
+ return VLC_ENOMEM;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
diff --git a/modules/codec/oggspots.c b/modules/codec/oggspots.c
index 0d7983b..4fbd6e4 100644
--- a/modules/codec/oggspots.c
+++ b/modules/codec/oggspots.c
@@ -250,9 +250,13 @@ static int ProcessHeader(decoder_t* p_dec)
* latter are underspecified. */
if (p_sys->b_packetizer) {
+ void* p_extra = realloc(p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra);
+ if (unlikely(p_extra == NULL)) {
+ return VLC_ENOMEM;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc(p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra);
memcpy(p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra);
}
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index d985e1d..32854c2 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -424,9 +424,14 @@ static int ProcessHeaders( decoder_t *p_dec )
if( p_sys->b_packetizer )
{
+ void* p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra );
+ if( unlikely( p_extra == NULL ) )
+ {
+ return VLC_ENOMEM;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index f1f100d..8212d19 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -399,9 +399,16 @@ static int ProcessHeaders( decoder_t *p_dec )
}
else
{
+ void* p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra );
+ if( unlikely( p_extra == NULL ) )
+ {
+ /* Clean up the decoder setup info... we're done with it */
+ th_setup_free( ts );
+ return VLC_ENOMEM;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index eef9578..c557032 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -414,9 +414,14 @@ static int ProcessHeaders( decoder_t *p_dec )
}
else
{
+ void* p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_in.i_extra );
+ if( unlikely( p_extra == NULL ) )
+ {
+ return VLC_ENOMEM;
+ }
+ p_dec->fmt_out.p_extra = p_extra;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
- p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
--
2.5.0
More information about the vlc-devel
mailing list