[xiph-cvs] cvs commit: ices/src playlist_basic.c

Michael Smith msmith at xiph.org
Fri Nov 9 21:07:17 PST 2001



msmith      01/11/09 21:07:17

  Modified:    src      playlist_basic.c
  Log:
  Memory leak. Fixed.

Revision  Changes    Path
1.5       +16 -8     ices/src/playlist_basic.c

Index: playlist_basic.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/playlist_basic.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- playlist_basic.c	2001/11/07 13:52:52	1.4
+++ playlist_basic.c	2001/11/10 05:07:17	1.5
@@ -1,7 +1,7 @@
 /* playlist_basic.c
  * - Simple built-in unscripted playlist
  *
- * $Id: playlist_basic.c,v 1.4 2001/11/07 13:52:52 msmith Exp $
+ * $Id: playlist_basic.c,v 1.5 2001/11/10 05:07:17 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -64,16 +64,18 @@
         {
                 LOG_ERROR2("Playlist file %s could not be opened: %s", 
                                 data->file, strerror(errno));
-		free(data);
                 return -1;
         }
 
 
-	if(data->pl)
-	{
+	if(data->pl) 
+    {
+        int i;
+        for(i = 0; i < data->len; i++)
+            free(data->pl[i]);
                 free(data->pl);
-		data->pl = NULL;
-	}
+    }
+	data->pl = NULL;
         data->len = 0;
         buflen = 0;
         while (1) 
@@ -111,8 +113,13 @@
         basic_playlist *pl = data;
         if(pl)
         {
-		if(pl->pl)
+		if(pl->pl) 
+        {
+            int i;
+            for(i=0; i < pl->len; i++)
+                free(pl->pl[i]);
                         free(pl->pl);
+        }
                 free(pl);
         }
 }
@@ -133,7 +140,8 @@
         if(st.st_mtime != pl->mtime)
         {
                 LOG_INFO1("Reloading playlist after file \"%s\" changed", pl->file);
-		load_playlist(pl);
+		if(load_playlist(pl) < 0)
+            return NULL;
         if(pl->restartafterreread)
             pl->pos = 0;
         }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list