[vlc-commits] directory: fix memory leak

Rémi Denis-Courmont git at videolan.org
Mon Jul 7 18:09:44 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul  7 19:09:31 2014 +0300| [0a19f3555ee942f120bda17b04786aad5126ef2f] | committer: Rémi Denis-Courmont

directory: fix memory leak

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

 modules/access/directory.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index e95bb2d..cf9396c 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -393,12 +393,15 @@ int DirRead (access_t *p_access, input_item_node_t *p_current_node)
         /* Create an input item for the current entry */
         psz_uri = encode_URI_component (psz_entry);
         if (psz_uri == NULL
-            || asprintf (&psz_full_uri, "%s/%s", p_current->uri, psz_uri) == -1)
+         || asprintf (&psz_full_uri, "%s/%s", p_current->uri, psz_uri) == -1)
+            psz_full_uri = NULL;
+
+        free (psz_uri);
+        if (psz_full_uri == NULL)
         {
             closedir (handle);
             continue;
         }
-        free (psz_uri);
 
         int i_type = i_res == ENTRY_DIR ? ITEM_TYPE_DIRECTORY : ITEM_TYPE_FILE;
         p_new = input_item_NewWithType (psz_full_uri, psz_entry,



More information about the vlc-commits mailing list