# HG changeset patch # User Calin Crisan ccrisan@gmail.com # Date 1215859421 -10800 # Node ID d608b16a710b28e08fb89b07e564a1c7137d5a9d # Parent 895d436200199f12a5889233655e9fe5f6492f76 fixed temporary files deletion diff -r 895d43620019 -r d608b16a710b src/streambrowser/shoutcast.c --- a/src/streambrowser/shoutcast.c Sat Jul 12 13:27:54 2008 +0300 +++ b/src/streambrowser/shoutcast.c Sat Jul 12 13:43:41 2008 +0300 @@ -23,11 +23,11 @@ char temp_pathname[DEF_STRING_LEN]; sprintf(temp_pathname, "file://%s", temp_filename); - free(temp_filename); debug("shoutcast: fetching category file '%s'\n", url); if (!fetch_remote_to_local_file(url, temp_pathname)) { failure("shoutcast: category file '%s' could not be downloaded to '%s'\n", url, temp_pathname); + free(temp_filename); return FALSE; } debug("shoutcast: category file '%s' successfuly downloaded to '%s'\n", url, temp_pathname); @@ -35,6 +35,7 @@ xmlDoc *doc = xmlReadFile(temp_pathname, NULL, 0); if (doc == NULL) { failure("shoutcast: failed to read '%s' category file\n", category->name); + free(temp_filename); return FALSE; } @@ -65,8 +66,11 @@ } } - remove(temp_filename); - // todo: free the mallocs() + if (remove(temp_filename) != 0) { + failure("shoutcast: cannot remove the temporary file: %s\n", strerror(errno)); + } + free(temp_filename); + // todo: free the xml mallocs() return TRUE; } @@ -85,11 +89,11 @@ char temp_pathname[DEF_STRING_LEN]; sprintf(temp_pathname, "file://%s", temp_filename); - free(temp_filename); debug("shoutcast: fetching streaming directory file '%s'\n", SHOUTCAST_STREAMDIR_URL); if (!fetch_remote_to_local_file(SHOUTCAST_STREAMDIR_URL, temp_pathname)) { failure("shoutcast: stream directory file '%s' could not be downloaded to '%s'\n", SHOUTCAST_STREAMDIR_URL, temp_pathname); + free(temp_filename); return NULL; } debug("shoutcast: stream directory file '%s' successfuly downloaded to '%s'\n", SHOUTCAST_STREAMDIR_URL, temp_pathname); @@ -97,6 +101,7 @@ xmlDoc *doc = xmlReadFile(temp_pathname, NULL, 0); if (doc == NULL) { failure("shoutcast: failed to read stream directory file\n"); + free(temp_filename); return NULL; } @@ -120,9 +125,13 @@ } } - // todo: free the mallocs() + // todo: free the xml mallocs() - remove(temp_filename); + if (remove(temp_filename) != 0) { + failure("shoutcast: cannot remove the temporary file: %s\n", strerror(errno)); + } + free(temp_filename); + debug("shoutcast: streaming directory successfuly loaded\n"); return streamdir;