[dvblast-devel] Check allocations in psi_unpack_sections().

Georgi Chorbadzhiyski git at videolan.org
Thu Jan 16 13:53:59 CET 2014


dvblast | branch: master | Georgi Chorbadzhiyski <gf at unixsol.org> | Thu Jan 16 14:45:21 2014 +0200| [245db42d327b4f1ccf1b3bcd899fa574b9190be2] | committer: Georgi Chorbadzhiyski

Check allocations in psi_unpack_sections().

Having unchecked allocations is recipe for dissaster.

> http://git.videolan.org/gitweb.cgi/dvblast.git/?a=commit;h=245db42d327b4f1ccf1b3bcd899fa574b9190be2
---

 util.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/util.c b/util.c
index 6a74de2..1be0aff 100644
--- a/util.c
+++ b/util.c
@@ -425,7 +425,10 @@ uint8_t **psi_unpack_sections( uint8_t *p_flat_sections, unsigned int i_size ) {
 
     pp_sections = psi_table_allocate();
     if ( !pp_sections )
+    {
+        msg_Err( NULL, "%s: cannot allocate PSI table\n", __func__ );
         return NULL;
+    }
 
     psi_table_init( pp_sections );
 
@@ -435,6 +438,12 @@ 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();
+        if ( !p_section_local )
+        {
+            msg_Err( NULL, "%s: cannot allocate PSI private\n", __func__ );
+            psi_table_free( pp_sections );
+            return NULL;
+        }
         memcpy( p_section_local, p_section, i_section_len );
         if ( !psi_table_section( pp_sections, p_section_local ) )
         {



More information about the dvblast-devel mailing list