Mercurial > audlegacy-plugins
comparison src/timidity/libtimidity/common.c @ 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 | fa9f85cebade |
| children |
comparison
equal
deleted
inserted
replaced
| 2267:2e961ce4bfe8 | 2268:bcd96cdc3a92 |
|---|---|
| 39 | 39 |
| 40 /* This is meant to find and open files for reading */ | 40 /* This is meant to find and open files for reading */ |
| 41 VFSFile *open_file(char *name) | 41 VFSFile *open_file(char *name) |
| 42 { | 42 { |
| 43 VFSFile *fp; | 43 VFSFile *fp; |
| 44 gchar* uri; | |
| 44 | 45 |
| 45 if (!name || !(*name)) | 46 if (!name || !(*name)) |
| 46 { | 47 { |
| 47 DEBUG_MSG("Attempted to open nameless file.\n"); | 48 DEBUG_MSG("Attempted to open nameless file.\n"); |
| 48 return 0; | 49 return 0; |
| 49 } | 50 } |
| 50 | 51 |
| 51 /* First try the given name */ | 52 /* First try the given name */ |
| 52 | 53 |
| 53 DEBUG_MSG("Trying to open %s\n", name); | 54 DEBUG_MSG("Trying to open %s\n", name); |
| 54 if ((fp = aud_vfs_fopen(g_filename_to_uri(name, NULL, NULL), OPEN_MODE))) | 55 uri = g_filename_to_uri(name, NULL, NULL); |
| 56 fp = aud_vfs_fopen(uri, OPEN_MODE); | |
| 57 g_free(uri); | |
| 58 if (fp) | |
| 55 return fp; | 59 return fp; |
| 56 | 60 |
| 57 if (name[0] != PATH_SEP) | 61 if (name[0] != PATH_SEP) |
| 58 { | 62 { |
| 59 char current_filename[1024]; | 63 char current_filename[1024]; |
| 73 current_filename[l + 1] = '\0'; | 77 current_filename[l + 1] = '\0'; |
| 74 } | 78 } |
| 75 } | 79 } |
| 76 strcat(current_filename, name); | 80 strcat(current_filename, name); |
| 77 DEBUG_MSG("Trying to open %s\n", current_filename); | 81 DEBUG_MSG("Trying to open %s\n", current_filename); |
| 78 if ((fp = aud_vfs_fopen(g_filename_to_uri(current_filename, NULL, NULL), OPEN_MODE))) | 82 uri = g_filename_to_uri(current_filename, NULL, NULL); |
| 83 fp = aud_vfs_fopen(uri, OPEN_MODE); | |
| 84 g_free(uri); | |
| 85 if (fp) | |
| 79 return fp; | 86 return fp; |
| 80 plp = plp->next; | 87 plp = plp->next; |
| 81 } | 88 } |
| 82 } | 89 } |
| 83 | 90 |
