[xiph-commits] r10151 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Tue Oct 11 06:40:20 PDT 2005


Author: karl
Date: 2005-10-11 06:40:17 -0700 (Tue, 11 Oct 2005)
New Revision: 10151

Modified:
   icecast/trunk/icecast/src/cfgfile.c
Log:
avoid adding a mount_t structure if there is no mount name defined, segv
occurs later on 


Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2005-10-11 06:29:27 UTC (rev 10150)
+++ icecast/trunk/icecast/src/cfgfile.c	2005-10-11 13:40:17 UTC (rev 10151)
@@ -113,6 +113,41 @@
     _set_defaults(configuration);
 }
 
+static void config_clear_mount (mount_proxy *mount)
+{
+    config_options_t *option;
+
+    xmlFree (mount->mountname);
+    xmlFree (mount->username);
+    xmlFree (mount->password);
+    xmlFree (mount->dumpfile);
+    xmlFree (mount->intro_filename);
+    xmlFree (mount->on_connect);
+    xmlFree (mount->on_disconnect);
+    xmlFree (mount->fallback_mount);
+    xmlFree (mount->stream_name);
+    xmlFree (mount->stream_description);
+    xmlFree (mount->stream_url);
+    xmlFree (mount->stream_genre);
+    xmlFree (mount->bitrate);
+    xmlFree (mount->type);
+    xmlFree (mount->cluster_password);
+
+    xmlFree (mount->auth_type);
+    option = mount->auth_options;
+    while (option)
+    {
+        config_options_t *nextopt = option->next;
+        xmlFree (option->name);
+        xmlFree (option->value);
+        free (option);
+        option = nextopt;
+    }
+    auth_release (mount->auth);
+    free (mount);
+}
+
+
 void config_clear(ice_config_t *c)
 {
     ice_config_dir_t *dirnode, *nextdirnode;
@@ -120,7 +155,6 @@
     mount_proxy *mount, *nextmount;
     aliases *alias, *nextalias;
     int i;
-    config_options_t *option;
 
     if (c->config_filename)
         free(c->config_filename);
@@ -183,36 +217,7 @@
     mount = c->mounts;
     while(mount) {
         nextmount = mount->next;
-        xmlFree(mount->mountname);
-        xmlFree(mount->username);
-        xmlFree(mount->password);
-        xmlFree(mount->dumpfile);
-        xmlFree(mount->intro_filename);
-        xmlFree(mount->on_connect);
-        xmlFree(mount->on_disconnect);
-        xmlFree(mount->fallback_mount);
-        xmlFree(mount->stream_name);
-        xmlFree(mount->stream_description);
-        xmlFree(mount->stream_url);
-        xmlFree(mount->stream_genre);
-        xmlFree(mount->bitrate);
-        xmlFree(mount->type);
-        if (mount->cluster_password) {
-            xmlFree(mount->cluster_password);
-        }
-
-        xmlFree(mount->auth_type);
-        option = mount->auth_options;
-        while(option) {
-            config_options_t *nextopt = option->next;
-            xmlFree(option->name);
-            xmlFree(option->value);
-            free(option);
-            option = nextopt;
-        }
-
-        auth_release (mount->auth);
-        free(mount);
+        config_clear_mount (mount);
         mount = nextmount;
     }
 
@@ -524,16 +529,6 @@
     mount_proxy *current = configuration->mounts;
     mount_proxy *last=NULL;
     
-    while(current) {
-        last = current;
-        current = current->next;
-    }
-
-    if(last)
-        last->next = mount;
-    else
-        configuration->mounts = mount;
-
     /* default <mount> settings */
     mount->max_listeners = -1;
     mount->burst_size = -1;
@@ -666,6 +661,22 @@
                     doc, node->xmlChildrenNode, 1);
         }
     } while ((node = node->next));
+
+    /* make sure we have at least the mountpoint name */
+    if (mount->mountname == NULL)
+    {
+        config_clear_mount (mount);
+        return;
+    }
+    while(current) {
+        last = current;
+        current = current->next;
+    }
+
+    if(last)
+        last->next = mount;
+    else
+        configuration->mounts = mount;
 }
 
 



More information about the commits mailing list