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

Francois Cartegnie git at videolan.org
Fri Feb 28 16:41:14 CET 2020


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

access: dvdnav: check titles alloc

(cherry picked from commit 021be3cc59dfe41f7150e68944a2e60a7bf048b2)

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

 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 d382155dd7..73f766d444 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -622,16 +622,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