]> git.sesse.net Git - vlc/blobdiff - src/modules/cache.c
Remove unmaintained SSA demuxer
[vlc] / src / modules / cache.c
index fd15dc991bce9cd49b4261d11cc20162a1233049..3f09ad8325ed6c3b9b0cd8d817ada68a5fcdebc6 100644 (file)
@@ -96,7 +96,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
 {
     char *psz_filename;
     FILE *file;
-    int j, i_size, i_read;
+    int i_size, i_read;
     char p_cachestring[sizeof(CACHE_STRING)];
     size_t i_cache;
     module_cache_t **pp_cache = NULL;
@@ -255,10 +255,17 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
         LOAD_STRING( pp_cache[i]->p_module->psz_help );
 
         LOAD_IMMEDIATE( pp_cache[i]->p_module->i_shortcuts );
-        pp_cache[i]->p_module->pp_shortcuts =
-                malloc( sizeof( char ** ) * pp_cache[i]->p_module->i_shortcuts );
-        for( j = 0; j < pp_cache[i]->p_module->i_shortcuts; j++ )
-            LOAD_STRING( pp_cache[i]->p_module->pp_shortcuts[j] );
+        if( pp_cache[i]->p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
+            goto error;
+        else if( pp_cache[i]->p_module->i_shortcuts == 0 )
+            pp_cache[i]->p_module->pp_shortcuts = NULL;
+        else
+        {
+            pp_cache[i]->p_module->pp_shortcuts =
+                    xmalloc( sizeof( char ** ) * pp_cache[i]->p_module->i_shortcuts );
+            for( unsigned j = 0; j < pp_cache[i]->p_module->i_shortcuts; j++ )
+                LOAD_STRING( pp_cache[i]->p_module->pp_shortcuts[j] );
+        }
 
         LOAD_STRING( pp_cache[i]->p_module->psz_capability );
         LOAD_IMMEDIATE( pp_cache[i]->p_module->i_score );
@@ -280,15 +287,23 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
         {
             module_t *p_module = vlc_submodule_create( pp_cache[i]->p_module );
             free( p_module->psz_object_name );
+            free( p_module->pp_shortcuts );
             LOAD_STRING( p_module->psz_object_name );
             LOAD_STRING( p_module->psz_shortname );
             LOAD_STRING( p_module->psz_longname );
             LOAD_STRING( p_module->psz_help );
 
             LOAD_IMMEDIATE( p_module->i_shortcuts );
-            p_module->pp_shortcuts = malloc( sizeof( char ** ) * p_module->i_shortcuts );
-            for( j = 0; j < p_module->i_shortcuts; j++ )
-                LOAD_STRING( p_module->pp_shortcuts[j] );
+            if( p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
+                goto error;
+            else if( p_module->i_shortcuts == 0 )
+                p_module->pp_shortcuts = NULL;
+            else
+            {
+                p_module->pp_shortcuts = xmalloc( sizeof( char ** ) * p_module->i_shortcuts );
+                for( unsigned j = 0; j < p_module->i_shortcuts; j++ )
+                    LOAD_STRING( p_module->pp_shortcuts[j] );
+            }
 
             LOAD_STRING( p_module->psz_capability );
             LOAD_IMMEDIATE( p_module->i_score );