[vlc-devel] commit: RTP: fix corner-case memory leak (fd_dead is a cancellation point) ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Jul 19 19:05:21 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 19 20:04:53 2009 +0300| [2c5de8fc0ed4da10ca7025bc1ac797ba1a29c381] | committer: Rémi Denis-Courmont 

RTP: fix corner-case memory leak (fd_dead is a cancellation point)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c5de8fc0ed4da10ca7025bc1ac797ba1a29c381
---

 modules/access/rtp/input.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/access/rtp/input.c b/modules/access/rtp/input.c
index 2d3d60f..e8bbad4 100644
--- a/modules/access/rtp/input.c
+++ b/modules/access/rtp/input.c
@@ -53,22 +53,23 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd)
     block_t *block = block_Alloc (0xffff);
     ssize_t len;
 
+    block_cleanup_push (block);
     do
     {
-        block_cleanup_push (block);
         len = net_Read (obj, fd, NULL,
                         block->p_buffer, block->i_buffer, false);
-        vlc_cleanup_pop ();
 
         if (((len <= 0) && fd_dead (fd)) || !vlc_object_alive (obj))
         {   /* POLLHUP -> permanent (DCCP) socket error */
             block_Release (block);
-            return NULL;
+            block = NULL;
+            break;
         }
     }
     while (len == -1);
+    vlc_cleanup_pop ();
 
-    return block_Realloc (block, 0, len);
+    return block ? block_Realloc (block, 0, len) : NULL;
 }
 
 




More information about the vlc-devel mailing list