[vlc-commits] [Git][videolan/vlc][master] 8 commits: daala: bail if block_Alloc failed
Tristan Matthews (@tmatth)
gitlab at videolan.org
Tue Dec 17 14:33:45 UTC 2024
Tristan Matthews pushed to branch master at VideoLAN / VLC
Commits:
a2716982 by Tristan Matthews at 2024-12-17T14:17:05+00:00
daala: bail if block_Alloc failed
- - - - -
c02a1978 by Tristan Matthews at 2024-12-17T14:17:05+00:00
dvbsub: bail if block_Alloc failed
- - - - -
eb97e5d0 by Tristan Matthews at 2024-12-17T14:17:05+00:00
fdkaac: bail if block_Alloc failed
- - - - -
a999703c by Tristan Matthews at 2024-12-17T14:17:05+00:00
flac: bail if block_Alloc failed
- - - - -
65e25e52 by Tristan Matthews at 2024-12-17T14:17:05+00:00
opus: bail if block_Alloc failed
- - - - -
28daa76a by Tristan Matthews at 2024-12-17T14:17:05+00:00
speex: bail if block_(Re)Alloc failed
- - - - -
e975295a by Tristan Matthews at 2024-12-17T14:17:05+00:00
theora: bail if block_Alloc failed
- - - - -
eaa118fe by Tristan Matthews at 2024-12-17T14:17:05+00:00
vorbis: bail if block_Alloc failed
- - - - -
8 changed files:
- modules/codec/daala.c
- modules/codec/dvbsub.c
- modules/codec/fdkaac.c
- modules/codec/flac.c
- modules/codec/opus.c
- modules/codec/speex.c
- modules/codec/theora.c
- modules/codec/vorbis.c
Changes:
=====================================
modules/codec/daala.c
=====================================
@@ -768,6 +768,9 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
/* Daala packet to block */
p_block = block_Alloc( dpacket.bytes );
+ if( unlikely(p_block == NULL) )
+ return NULL;
+
memcpy( p_block->p_buffer, dpacket.packet, dpacket.bytes );
p_block->i_dts = p_block->i_pts = p_pict->date;
=====================================
modules/codec/dvbsub.c
=====================================
@@ -1992,6 +1992,9 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
msg_Dbg( p_enc, "encoding subpicture" );
#endif
p_block = block_Alloc( 64000 );
+ if( unlikely(p_block == NULL) )
+ return NULL;
+
bs_init( s, p_block->p_buffer, p_block->i_buffer );
bs_write( s, 8, 0x20 ); /* Data identifier */
@@ -2020,6 +2023,12 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
/* Send another (empty) subtitle to signal the end of display */
p_block_stop = block_Alloc( 64000 );
+ if( unlikely(p_block_stop == NULL) )
+ {
+ block_Release(p_block);
+ return NULL;
+ }
+
bs_init( s, p_block_stop->p_buffer, p_block_stop->i_buffer );
bs_write( s, 8, 0x20 ); /* Data identifier */
bs_write( s, 8, 0x0 ); /* Subtitle stream id */
=====================================
modules/codec/fdkaac.c
=====================================
@@ -388,6 +388,9 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf)
in_buf.bufElSizes = &in_elem_size;
block_t *p_block;
p_block = block_Alloc(p_sys->i_maxoutputsize);
+ if (unlikely(p_block == NULL)) {
+ break;
+ }
p_block->i_buffer = p_sys->i_maxoutputsize;
out_ptr = p_block->p_buffer;
out_size = p_block->i_buffer;
=====================================
modules/codec/flac.c
=====================================
@@ -764,6 +764,11 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
}
p_block = block_Alloc( bytes );
+ /* FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR would be more appropriate
+ but it's not the right type of enum */
+ if( unlikely(p_block == NULL) )
+ return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
+
memcpy( p_block->p_buffer, buffer, bytes );
p_block->i_dts = p_block->i_pts = p_sys->i_pts;
=====================================
modules/codec/opus.c
=====================================
@@ -689,6 +689,11 @@ static block_t *Encode(encoder_t *enc, block_t *buf)
while (sys->i_nb_samples + buf->i_nb_samples >= OPUS_FRAME_SIZE)
{
block_t *out_block = block_Alloc(OPUS_MAX_ENCODED_BYTES);
+ if (unlikely(out_block == NULL))
+ {
+ block_ChainRelease(result);
+ return NULL;
+ }
/* add padding to beginning */
if (sys->padding)
=====================================
modules/codec/speex.c
=====================================
@@ -606,6 +606,9 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
/ 8;
p_new_block = block_Alloc( i_bytes_in_speex_frame );
+ if( unlikely(p_new_block == NULL) )
+ return NULL;
+
memset( p_new_block->p_buffer, 0xff, i_bytes_in_speex_frame );
/*
@@ -635,9 +638,13 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
speex_bits_write( &p_sys->bits,
(char*)p_block->p_buffer,
p_block->i_buffer - i_bytes_in_speex_frame );
+
p_block = block_Realloc( p_block,
0,
p_block->i_buffer-i_bytes_in_speex_frame );
+ if( unlikely(p_block == NULL) )
+ return NULL;
+
*pp_block = p_block;
}
else
@@ -1158,6 +1165,9 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
speex_bits_reset( &p_sys->bits );
p_block = block_Alloc( i_out );
+ if( unlikely(p_block == NULL) )
+ break;
+
memcpy( p_block->p_buffer, p_sys->p_buffer_out, i_out );
p_block->i_length = vlc_tick_from_samples(
=====================================
modules/codec/theora.c
=====================================
@@ -904,6 +904,9 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
/* Ogg packet to block */
p_block = block_Alloc( oggpacket.bytes );
+ if( unlikely(p_block == NULL) )
+ return NULL;
+
memcpy( p_block->p_buffer, oggpacket.packet, oggpacket.bytes );
p_block->i_dts = p_block->i_pts = p_pict->date;
=====================================
modules/codec/vorbis.c
=====================================
@@ -939,6 +939,12 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
{
int i_block_size;
p_block = block_Alloc( oggpacket.bytes );
+ if( unlikely(p_block == NULL) ) {
+ block_ChainRelease( p_chain );
+ p_chain = NULL;
+ break;
+ }
+
memcpy( p_block->p_buffer, oggpacket.packet, oggpacket.bytes );
i_block_size = vorbis_packet_blocksize( &p_sys->vi, &oggpacket );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a945944c2d50cacfacdd5b16d4ea5e7b4766a9fc...eaa118fe468e2ce7d9f7f18bea9567dfa85a2277
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a945944c2d50cacfacdd5b16d4ea5e7b4766a9fc...eaa118fe468e2ce7d9f7f18bea9567dfa85a2277
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list