[vlc-commits] access: dvdnav: check titles alloc

Francois Cartegnie git at videolan.org
Mon Jan 27 22:56:14 CET 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan 24 16:19:28 2020 +0100| [021be3cc59dfe41f7150e68944a2e60a7bf048b2] | committer: Francois Cartegnie

access: dvdnav: check titles alloc

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=021be3cc59dfe41f7150e68944a2e60a7bf048b2
---

 modules/access/dvdnav.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 24bf9bbb0d..5ec07496bb 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -598,16 +598,25 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TITLE_INFO:
             ppp_title = va_arg( args, input_title_t*** );
-            *va_arg( args, int* ) = p_sys->i_title;
-            *va_arg( args, int* ) = 0; /* Title offset */
-            *va_arg( args, int* ) = 1; /* Chapter offset */
 
             /* Duplicate title infos */
             *ppp_title = vlc_alloc( p_sys->i_title, sizeof( input_title_t * ) );
+            if( !*ppp_title )
+                return VLC_EGENERIC;
             for( i = 0; i < p_sys->i_title; i++ )
             {
                 (*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->title[i] );
+                if(!(*ppp_title)[i])
+                {
+                    while( i )
+                        free( (*ppp_title)[--i] );
+                    free( *ppp_title );
+                    return VLC_EGENERIC;
+                }
             }
+            *va_arg( args, int* ) = p_sys->i_title;
+            *va_arg( args, int* ) = 0; /* Title offset */
+            *va_arg( args, int* ) = 1; /* Chapter offset */
             return VLC_SUCCESS;
 
         case DEMUX_SET_TITLE:



More information about the vlc-commits mailing list