[Bug] Memleak in libhttp.c

Hervé Rousseau herve+getstream at moulticast.net
Sun Aug 23 17:18:12 CEST 2009


Hi there,

While packaging getstream for Debian, someone from the Debian Devel
list (George Danchev) reported a possible memleak in the code, he also
included a patch.

Here is what he said :


[...]

There is also a very innocent memory leak you might want to fix:

--- libhttp.c.orig      2009-08-23 16:36:05.000000000 +0200
+++ libhttp.c   2009-08-23 16:39:43.000000000 +0200
@@ -556,11 +556,15 @@
       hs->sin.sin_addr.s_addr=INADDR_ANY;

       if (bind(hs->fd, (struct sockaddr *) &hs->sin,
-                               sizeof(struct sockaddr_in)))
+                               sizeof(struct sockaddr_in))) {
+               free(hs);
               return NULL;
+       }

-       if (listen(hs->fd, 3))
+       if (listen(hs->fd, 3)) {
+               free(hs);
               return NULL;
+       }

       flags=fcntl(hs->fd, F_GETFL);
       fcntl(hs->fd, F_GETFL, flags | O_NONBLOCK);

Cheers,

--
Herve Rousseau


More information about the Getstream mailing list