[libdvdcss-devel] [PATCH 29/47] css: Check the return value of a malloc() invocation

Diego Biurrun diego at biurrun.de
Wed Oct 29 21:33:29 CET 2014


This prevents a possible NULL pointer dereference further along.
---
 src/css.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/css.c b/src/css.c
index 3d73080..90957d5 100644
--- a/src/css.c
+++ b/src/css.c
@@ -297,6 +297,10 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
 
     /* Write in the new title and its key */
     p_newtitle = malloc( sizeof( dvd_title_t ) );
+    if( p_newtitle == NULL )
+    {
+        return -1;
+    }
     p_newtitle->i_startlb = i_block;
     memcpy( p_newtitle->p_key, p_title_key, KEY_SIZE );
 
-- 
1.9.1



More information about the libdvdcss-devel mailing list