[vlc-devel] [PATCH] ogg codecs: use checked realloc() instead of xrealloc()
Michael Tänzer
neo at nhng.de
Fri Mar 4 02:20:57 CET 2016
---
modules/codec/daala.c | 7 ++++++-
modules/codec/kate.c | 8 ++++++--
modules/codec/oggspots.c | 7 +++++--
modules/codec/speex.c | 8 ++++++--
modules/codec/theora.c | 10 ++++++++--
modules/codec/vorbis.c | 8 ++++++--
6 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/modules/codec/daala.c b/modules/codec/daala.c
index ae790dd..47ae15e 100644
--- a/modules/codec/daala.c
+++ b/modules/codec/daala.c
@@ -381,8 +381,13 @@ static int ProcessHeaders( decoder_t *p_dec )
else
{
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.p_extra = realloc( p_dec->fmt_out.p_extra,
p_dec->fmt_out.i_extra );
+ if( p_dec->fmt_out.p_extra == NULL )
+ {
+ ret = VLC_ENOMEM;
+ goto cleanup;
+ }
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..06fdf48 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -593,8 +593,12 @@ static int ProcessHeaders( decoder_t *p_dec )
else
{
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 );
+ p_dec->fmt_out.p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ return VLC_ENOMEM;
+ }
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..f5ced55 100644
--- a/modules/codec/oggspots.c
+++ b/modules/codec/oggspots.c
@@ -251,8 +251,11 @@ static int ProcessHeader(decoder_t* p_dec)
if (p_sys->b_packetizer) {
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);
+ p_dec->fmt_out.p_extra = realloc(p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra);
+ if (p_dec->fmt_out.p_extra == NULL) {
+ return VLC_ENOMEM;
+ }
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..bddd570 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -425,8 +425,12 @@ static int ProcessHeaders( decoder_t *p_dec )
if( p_sys->b_packetizer )
{
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 );
+ p_dec->fmt_out.p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ return VLC_ENOMEM;
+ }
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..9d899b4 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -400,8 +400,14 @@ static int ProcessHeaders( decoder_t *p_dec )
else
{
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 );
+ p_dec->fmt_out.p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ /* Clean up the decoder setup info... we're done with it */
+ th_setup_free( ts );
+ return VLC_ENOMEM;
+ }
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..61a534a 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -415,8 +415,12 @@ static int ProcessHeaders( decoder_t *p_dec )
else
{
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 );
+ p_dec->fmt_out.p_extra = realloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ return VLC_ENOMEM;
+ }
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