[vlc-commits] modules: cache: fix leaking path on error (cid #1048948)

Francois Cartegnie git at videolan.org
Fri Jan 1 18:17:56 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan  1 18:16:02 2016 +0100| [e8e468fbbc27a4ed8e71613f289d5969e3ccd305] | committer: Francois Cartegnie

modules: cache: fix leaking path on error (cid #1048948)

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

 src/modules/cache.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/modules/cache.c b/src/modules/cache.c
index b529a4a..a08496d 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -362,6 +362,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
 
     module_cache_t *cache = NULL;
     size_t count = 0;
+    char *path = NULL;
 
     for (;;)
     {
@@ -373,7 +374,6 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
             goto error;
         }
 
-        char *path;
         struct stat st;
 
         /* Load common info */
@@ -385,6 +385,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
 
         CacheAdd (&cache, &count, path, &st, module);
         free (path);
+        path = NULL;
         /* TODO: deal with errors */
     }
 
@@ -394,6 +395,7 @@ size_t CacheLoad( vlc_object_t *p_this, const char *dir, module_cache_t **r )
     return count;
 
 error:
+    free( path );
     if (ferror (file))
         msg_Err(p_this, "plugins cache read error: %s", vlc_strerror_c(errno));
     msg_Warn( p_this, "plugins cache not loaded (corrupted)" );



More information about the vlc-commits mailing list