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

karl at svn.xiph.org karl at svn.xiph.org
Mon Jul 4 13:11:19 PDT 2005


Author: karl
Date: 2005-07-04 13:11:15 -0700 (Mon, 04 Jul 2005)
New Revision: 9547

Modified:
   icecast/trunk/icecast/src/stats.c
   icecast/trunk/icecast/src/xslt.c
Log:
some xslt related fixes. A small memory leak, a socket not closing on odd
case, and truncate the buffer length so that junk chars are not sent back.


Modified: icecast/trunk/icecast/src/stats.c
===================================================================
--- icecast/trunk/icecast/src/stats.c	2005-07-03 23:30:26 UTC (rev 9546)
+++ icecast/trunk/icecast/src/stats.c	2005-07-04 20:11:15 UTC (rev 9547)
@@ -897,6 +897,7 @@
     xslt_transform(doc, xslpath, client);
 
     xmlFreeDoc(doc);
+    free (xslpath);
 }
 
 void stats_get_xml(xmlDocPtr *doc, int show_hidden)

Modified: icecast/trunk/icecast/src/xslt.c
===================================================================
--- icecast/trunk/icecast/src/xslt.c	2005-07-03 23:30:26 UTC (rev 9546)
+++ icecast/trunk/icecast/src/xslt.c	2005-07-04 20:11:15 UTC (rev 9547)
@@ -156,7 +156,7 @@
     xmlDocPtr    res;
     xsltStylesheetPtr cur;
     xmlChar *string;
-    int len;
+    int len, problem = 0;
 
     thread_mutex_lock(&xsltlock);
     cur = xslt_get_stylesheet(xslfilename);
@@ -171,19 +171,28 @@
 
     res = xsltApplyStylesheet(cur, doc, NULL);
 
-    xsltSaveResultToString (&string, &len, res, cur);
+    if (xsltSaveResultToString (&string, &len, res, cur) < 0)
+        problem = 1;
     thread_mutex_unlock(&xsltlock);
-    if (string)
+    if (problem == 0)
     {
         const char *http = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: ";
-        unsigned buf_len = strlen (http) + 20 + len;
+        int buf_len = strlen (http) + 20 + len;
 
+        if (string == NULL)
+            string = xmlStrdup ("");
         client->respcode = 200;
         client->refbuf = refbuf_new (buf_len);
-        snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, string);
+        len = snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, string);
+        client->refbuf->len = len;
         fserve_add_client (client, NULL);
         xmlFree (string);
     }
+    else
+    {
+        WARN1 ("problem applying stylesheet \"%s\"", xslfilename);
+        client_send_404 (client, "XSLT problem");
+    }
     xmlFreeDoc(res);
 }
 



More information about the commits mailing list