changeset 2268:bcd96cdc3a92

Fixes memleaks in open_file() function of libtimidity (Bugzilla #27)
author Jussi Judin <jjudin+audacious@iki.fi>
date Tue, 25 Dec 2007 02:16:22 -0600
parents 2e961ce4bfe8
children c44b90b6322e
files src/timidity/libtimidity/common.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/timidity/libtimidity/common.c	Tue Dec 25 02:15:51 2007 -0600
+++ b/src/timidity/libtimidity/common.c	Tue Dec 25 02:16:22 2007 -0600
@@ -41,6 +41,7 @@
 VFSFile *open_file(char *name)
 {
   VFSFile *fp;
+  gchar* uri;
 
   if (!name || !(*name))
     {
@@ -51,7 +52,10 @@
   /* First try the given name */
 
   DEBUG_MSG("Trying to open %s\n", name);
-  if ((fp = aud_vfs_fopen(g_filename_to_uri(name, NULL, NULL), OPEN_MODE)))
+  uri = g_filename_to_uri(name, NULL, NULL);
+  fp = aud_vfs_fopen(uri, OPEN_MODE);
+  g_free(uri);
+  if (fp)
     return fp;
 
   if (name[0] != PATH_SEP)
@@ -75,7 +79,10 @@
 	  }
 	strcat(current_filename, name);
 	DEBUG_MSG("Trying to open %s\n", current_filename);
-	if ((fp = aud_vfs_fopen(g_filename_to_uri(current_filename, NULL, NULL), OPEN_MODE)))
+	uri = g_filename_to_uri(current_filename, NULL, NULL);
+	fp = aud_vfs_fopen(uri, OPEN_MODE);
+	g_free(uri);
+	if (fp)
 	  return fp;
 	plp = plp->next;
       }