[vlc-commits] decomp: fix leak on error and clean up a little
Rémi Denis-Courmont
git at videolan.org
Tue Apr 16 21:09:14 CEST 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 16 21:17:39 2013 +0300| [ddece1c533efeffec235a190f44a72853a604ea7] | committer: Rémi Denis-Courmont
decomp: fix leak on error and clean up a little
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ddece1c533efeffec235a190f44a72853a604ea7
---
modules/stream_filter/decomp.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index 82bb5e9..28a98bd 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -71,11 +71,17 @@ vlc_module_end ()
struct stream_sys_t
{
- block_t *peeked;
- uint64_t offset;
+ /* Thread data */
+ int write_fd;
+
+ /* Caller data */
vlc_thread_t thread;
pid_t pid;
- int write_fd, read_fd;
+
+ uint64_t offset;
+ block_t *peeked;
+
+ int read_fd;
bool can_pace;
};
@@ -277,9 +283,10 @@ static int Open (stream_t *stream, const char *path)
stream->pf_read = Read;
stream->pf_peek = Peek;
stream->pf_control = Control;
- p_sys->peeked = NULL;
- p_sys->offset = 0;
+
p_sys->pid = -1;
+ p_sys->offset = 0;
+ p_sys->peeked = NULL;
stream_Control (stream->p_source, STREAM_CAN_CONTROL_PACE,
&p_sys->can_pace);
@@ -344,12 +351,15 @@ static int Open (stream_t *stream, const char *path)
}
close (comp[0]);
if (ret != VLC_SUCCESS)
- {
close (comp[1]);
- if (p_sys->pid != -1)
- while (waitpid (p_sys->pid, &(int){ 0 }, 0) == -1);
- }
}
+
+ if (ret == VLC_SUCCESS)
+ return VLC_SUCCESS;
+
+ if (p_sys->pid != -1)
+ while (waitpid (p_sys->pid, &(int){ 0 }, 0) == -1);
+ free (p_sys);
return ret;
}
More information about the vlc-commits
mailing list