[vlc-devel] commit: access_directory: fix memleaks. ( Rémi Duraffort )

git version control git at videolan.org
Sat May 30 00:32:48 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu May 28 14:34:21 2009 +0200| [a1c9010bb45c5a0e4a8888e495b6055115391dbd] | committer: Jean-Baptiste Kempf 

access_directory: fix memleaks.
(cherry picked from commit cbe9981163a222b2e57ad266881750fdf6b5d2b2)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/access/directory.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index 05b6ec1..dd04b6a 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -307,6 +307,7 @@ static block_t *Block (access_t *p_access)
     {   /* End of directory, go back to parent */
         closedir (current->handle);
         p_sys->current = current->parent;
+        free (current->uri);
         free (current);
 
         if (p_sys->current == NULL)
@@ -346,14 +347,20 @@ static block_t *Block (access_t *p_access)
 
     /* Skip current, parent and hidden directories */
     if (entry[0] == '.')
+    {
+        free (entry);
         return NULL;
+    }
     /* Handle recursion */
     if (p_sys->mode != MODE_COLLAPSE)
     {
         directory_t *sub = malloc (sizeof (*sub) + strlen (current->path) + 1
                                                  + strlen (entry));
         if (sub == NULL)
+        {
+            free (entry);
             return NULL;
+        }
         sprintf (sub->path, "%s/%s", current->path, entry);
 
         DIR *handle = utf8_opendir (sub->path);
@@ -373,7 +380,9 @@ static block_t *Block (access_t *p_access)
              || has_inode_loop (sub)
              || (sub->uri == NULL))
             {
+                free (entry);
                 closedir (handle);
+                free (sub->uri);
                 free (sub);
                 return NULL;
             }
@@ -382,9 +391,13 @@ static block_t *Block (access_t *p_access)
             /* Add node to xspf extension */
             char *old_xspf_extension = p_sys->psz_xspf_extension;
             if (old_xspf_extension == NULL)
+            {
+                free (entry);
                 goto fatal;
+            }
 
             char *title = convert_xml_special_chars (entry);
+            free (entry);
             if (title == NULL
              || asprintf (&p_sys->psz_xspf_extension, "%s"
                           "  <vlc:node title=\"%s\">\n", old_xspf_extension,
@@ -417,7 +430,10 @@ static block_t *Block (access_t *p_access)
 
                 if (type + extlen == end
                  && !strncasecmp (ext, type, extlen))
+                {
+                    free (entry);
                     return NULL;
+                }
 
                 if (*end == '\0')
                     break;




More information about the vlc-devel mailing list