Commit 7474c473 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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

(cherry picked from commit 2c5de8fc)
parent 3e254a1a
...@@ -53,22 +53,23 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd) ...@@ -53,22 +53,23 @@ static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd)
block_t *block = block_Alloc (0xffff); block_t *block = block_Alloc (0xffff);
ssize_t len; ssize_t len;
block_cleanup_push (block);
do do
{ {
block_cleanup_push (block);
len = net_Read (obj, fd, NULL, len = net_Read (obj, fd, NULL,
block->p_buffer, block->i_buffer, false); block->p_buffer, block->i_buffer, false);
vlc_cleanup_pop ();
if (((len <= 0) && fd_dead (fd)) || !vlc_object_alive (obj)) if (((len <= 0) && fd_dead (fd)) || !vlc_object_alive (obj))
{ /* POLLHUP -> permanent (DCCP) socket error */ { /* POLLHUP -> permanent (DCCP) socket error */
block_Release (block); block_Release (block);
return NULL; block = NULL;
break;
} }
} }
while (len == -1); while (len == -1);
vlc_cleanup_pop ();
return block_Realloc (block, 0, len); return block ? block_Realloc (block, 0, len) : NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment