[xiph-commits] r7916 - icecast/branches/kh/net

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Tue Oct 5 15:00:46 PDT 2004


Author: karl
Date: 2004-10-05 15:00:45 -0700 (Tue, 05 Oct 2004)
New Revision: 7916

Modified:
   icecast/branches/kh/net/sock.c
Log:
missing free causing small memory leak. limit size to 2Meg


Modified: icecast/branches/kh/net/sock.c
===================================================================
--- icecast/branches/kh/net/sock.c	2004-10-05 12:12:40 UTC (rev 7915)
+++ icecast/branches/kh/net/sock.c	2004-10-05 22:00:45 UTC (rev 7916)
@@ -370,23 +370,25 @@
     char *buff = NULL;
     int ret;
 
-    /* don't go infinite, but stop at some hugh limit */
-    while (len < 5*1024*1024)
+    /* don't go infinite, but stop at some huge limit */
+    while (len < 2*1024*1024)
     {
         char *tmp = realloc (buff, len);
+        ret = -1;
         if (tmp == NULL)
-        {
-            free (buff);
-            return -1;
-        }
+            break;
         buff = tmp;
         va_copy (ap_local, ap);
         ret = vsnprintf (buff, len, fmt, ap_local);
         if (ret > 0)
-            return sock_write_bytes (sock, buff, ret);
+        {
+            ret = sock_write_bytes (sock, buff, ret);
+            break;
+        }
         len += 8192;
     }
-    return -1;
+    free (buff);
+    return ret;
 }
 #else
 int sock_write_fmt(sock_t sock, const char *fmt, va_list ap)



More information about the commits mailing list