[dvblast-devel] Check return value of functions that may fail.
Georgi Chorbadzhiyski
git at videolan.org
Thu Oct 24 15:22:44 CEST 2013
dvblast | branch: master | Georgi Chorbadzhiyski <gf at unixsol.org> | Thu Oct 24 16:21:31 2013 +0300| [facec802e6ac2b7aa006d943adac3cfb0abd00d3] | committer: Georgi Chorbadzhiyski
Check return value of functions that may fail.
Found by Coverity: CID 1109721
> http://git.videolan.org/gitweb.cgi/dvblast.git/?a=commit;h=facec802e6ac2b7aa006d943adac3cfb0abd00d3
---
dvblastctl.c | 5 +++++
util.c | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dvblastctl.c b/dvblastctl.c
index 5a44d52..438bac0 100644
--- a/dvblastctl.c
+++ b/dvblastctl.c
@@ -546,6 +546,11 @@ int main( int i_argc, char **ppsz_argv )
uint8_t *p_flat_data = p_buffer + COMM_HEADER_SIZE;
unsigned int i_flat_data_size = i_size - COMM_HEADER_SIZE;
uint8_t **pp_sections = psi_unpack_sections( p_flat_data, i_flat_data_size );
+ if ( !pp_sections )
+ {
+ return_error( "Error unpacking PSI" );
+ break;
+ }
switch( c_answer )
{
diff --git a/util.c b/util.c
index 949c28e..14b1db5 100644
--- a/util.c
+++ b/util.c
@@ -423,6 +423,9 @@ uint8_t **psi_unpack_sections( uint8_t *p_flat_sections, unsigned int i_size ) {
unsigned int i, i_offset = 0;
pp_sections = psi_table_allocate();
+ if ( !pp_sections )
+ return NULL;
+
psi_table_init( pp_sections );
for ( i = 0; i < PSI_TABLE_MAX_SECTIONS; i++ ) {
@@ -432,7 +435,11 @@ uint8_t **psi_unpack_sections( uint8_t *p_flat_sections, unsigned int i_size ) {
/* Must use allocated section not p_flat_section + offset directly! */
uint8_t *p_section_local = psi_private_allocate();
memcpy( p_section_local, p_section, i_section_len );
- psi_table_section( pp_sections, p_section_local );
+ if ( !psi_table_section( pp_sections, p_section_local ) )
+ {
+ psi_table_free( pp_sections );
+ return NULL;
+ }
i_offset += i_section_len;
if ( i_offset >= i_size - 1 )
More information about the dvblast-devel
mailing list