[vlc-devel] commit: Fix corner case memory leak ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Jun 29 17:21:20 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Jun 29 18:21:10 2008 +0300| [1d2139aa05982eb40df53cf4f04e5c34196e7217]
Fix corner case memory leak
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d2139aa05982eb40df53cf4f04e5c34196e7217
---
modules/codec/schroedinger.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/modules/codec/schroedinger.c b/modules/codec/schroedinger.c
index 955ff7c..46245f8 100644
--- a/modules/codec/schroedinger.c
+++ b/modules/codec/schroedinger.c
@@ -112,18 +112,23 @@ static int OpenDecoder( vlc_object_t *p_this )
return VLC_EGENERIC;
}
+ /* Allocate the memory needed to store the decoder's structure */
+ p_sys = malloc(sizeof(decoder_sys_t));
+ if( p_sys == NULL )
+ return VLC_ENOMEM;
+
/* Initialise the schroedinger (and hence liboil libraries */
/* This does no allocation and is safe to call */
schro_init();
/* Initialise the schroedinger decoder */
- if( !(p_schro = schro_decoder_new()) ) return VLC_EGENERIC;
-
- /* Allocate the memory needed to store the decoder's structure */
- if( ( p_dec->p_sys = p_sys =
- (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
- return VLC_ENOMEM;
+ if( !(p_schro = schro_decoder_new()) )
+ {
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
+ p_dec->p_sys = p_sys;
p_sys->p_schro = p_schro;
p_sys->p_format = NULL;
p_sys->i_lastpts = -1;
More information about the vlc-devel
mailing list