Skip to content

Commit fcedf52

Browse files
NEOatNHNGjbkempf
authored andcommitted
ogg codecs: use checked realloc() instead of xrealloc()
Signed-off-by: Jean-Baptiste Kempf <[email protected]>
1 parent 37a9c77 commit fcedf52

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed

modules/codec/daala.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,15 @@ static int ProcessHeaders( decoder_t *p_dec )
380380
}
381381
else
382382
{
383+
void* p_extra = realloc( p_dec->fmt_out.p_extra,
384+
p_dec->fmt_in.i_extra );
385+
if( unlikely( p_extra == NULL ) )
386+
{
387+
ret = VLC_ENOMEM;
388+
goto cleanup;
389+
}
390+
p_dec->fmt_out.p_extra = p_extra;
383391
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
384-
p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
385-
p_dec->fmt_out.i_extra );
386392
memcpy( p_dec->fmt_out.p_extra,
387393
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
388394
}

modules/codec/kate.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,14 @@ static int ProcessHeaders( decoder_t *p_dec )
592592
#ifdef ENABLE_PACKETIZER
593593
else
594594
{
595+
void* p_extra = realloc( p_dec->fmt_out.p_extra,
596+
p_dec->fmt_in.i_extra );
597+
if( unlikely( p_extra == NULL ) )
598+
{
599+
return VLC_ENOMEM;
600+
}
601+
p_dec->fmt_out.p_extra = p_extra;
595602
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
596-
p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
597-
p_dec->fmt_out.i_extra );
598603
memcpy( p_dec->fmt_out.p_extra,
599604
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
600605
}

modules/codec/oggspots.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ static int ProcessHeader(decoder_t* p_dec)
250250
* latter are underspecified. */
251251

252252
if (p_sys->b_packetizer) {
253+
void* p_extra = realloc(p_dec->fmt_out.p_extra,
254+
p_dec->fmt_in.i_extra);
255+
if (unlikely(p_extra == NULL)) {
256+
return VLC_ENOMEM;
257+
}
258+
p_dec->fmt_out.p_extra = p_extra;
253259
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
254-
p_dec->fmt_out.p_extra = xrealloc(p_dec->fmt_out.p_extra,
255-
p_dec->fmt_out.i_extra);
256260
memcpy(p_dec->fmt_out.p_extra,
257261
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra);
258262
}

modules/codec/speex.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,14 @@ static int ProcessHeaders( decoder_t *p_dec )
424424

425425
if( p_sys->b_packetizer )
426426
{
427+
void* p_extra = realloc( p_dec->fmt_out.p_extra,
428+
p_dec->fmt_in.i_extra );
429+
if( unlikely( p_extra == NULL ) )
430+
{
431+
return VLC_ENOMEM;
432+
}
433+
p_dec->fmt_out.p_extra = p_extra;
427434
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
428-
p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
429-
p_dec->fmt_out.i_extra );
430435
memcpy( p_dec->fmt_out.p_extra,
431436
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
432437
}

modules/codec/theora.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,16 @@ static int ProcessHeaders( decoder_t *p_dec )
399399
}
400400
else
401401
{
402+
void* p_extra = realloc( p_dec->fmt_out.p_extra,
403+
p_dec->fmt_in.i_extra );
404+
if( unlikely( p_extra == NULL ) )
405+
{
406+
/* Clean up the decoder setup info... we're done with it */
407+
th_setup_free( ts );
408+
return VLC_ENOMEM;
409+
}
410+
p_dec->fmt_out.p_extra = p_extra;
402411
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
403-
p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
404-
p_dec->fmt_out.i_extra );
405412
memcpy( p_dec->fmt_out.p_extra,
406413
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
407414
}

modules/codec/vorbis.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,14 @@ static int ProcessHeaders( decoder_t *p_dec )
414414
}
415415
else
416416
{
417+
void* p_extra = realloc( p_dec->fmt_out.p_extra,
418+
p_dec->fmt_in.i_extra );
419+
if( unlikely( p_extra == NULL ) )
420+
{
421+
return VLC_ENOMEM;
422+
}
423+
p_dec->fmt_out.p_extra = p_extra;
417424
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
418-
p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
419-
p_dec->fmt_out.i_extra );
420425
memcpy( p_dec->fmt_out.p_extra,
421426
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
422427
}

0 commit comments

Comments
 (0)