[vlc-commits] Revert "libvlc: fix leaks if init fails"
Rémi Denis-Courmont
git at videolan.org
Tue Sep 20 16:50:34 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Sep 20 17:49:55 2016 +0300| [0640f103865849973553153d8f79b1150307a58f] | committer: Rémi Denis-Courmont
Revert "libvlc: fix leaks if init fails"
This reverts commit 67dc5082c467b5b544e41c71a11c8eb438f87161, which
broke the test suite.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0640f103865849973553153d8f79b1150307a58f
---
lib/core.c | 1 -
src/libvlc.c | 38 +++++++++++++++++++++-----------------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/lib/core.c b/lib/core.c
index c0f9904..b06ed67 100644
--- a/lib/core.c
+++ b/lib/core.c
@@ -102,7 +102,6 @@ void libvlc_release( libvlc_instance_t *p_instance )
vlc_mutex_destroy( lock );
if( p_instance->libvlc_vlm.pf_release )
p_instance->libvlc_vlm.pf_release( p_instance );
- libvlc_Quit( p_instance->p_libvlc_int );
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int );
free( p_instance );
diff --git a/src/libvlc.c b/src/libvlc.c
index 4ae358f..48c2b8c 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -125,7 +125,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
char * psz_parser = NULL;
char * psz_control = NULL;
char *psz_val;
- int i_ret = VLC_EGENERIC;
/* System specific initialization code */
system_Init();
@@ -169,7 +168,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
*/
int vlc_optind;
if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, &vlc_optind ) )
- goto error;
+ {
+ vlc_LogDeinit (p_libvlc);
+ module_EndBank (true);
+ return VLC_EGENERIC;
+ }
vlc_LogInit(p_libvlc);
@@ -184,13 +187,17 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") );
if (config_PrintHelp (VLC_OBJECT(p_libvlc)))
- goto error;
+ {
+ module_EndBank (true);
+ exit(0);
+ }
if( module_count <= 1 )
{
msg_Err( p_libvlc, "No plugins found! Check your VLC installation.");
- i_ret = VLC_ENOMOD;
- goto error;
+ vlc_LogDeinit (p_libvlc);
+ module_EndBank (true);
+ return VLC_ENOMOD;
}
#ifdef HAVE_DAEMON
@@ -200,7 +207,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( daemon( 1, 0) != 0 )
{
msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" );
- goto error;
+ vlc_LogDeinit (p_libvlc);
+ module_EndBank (true);
+ return VLC_ENOMEM;
}
/* lets check if we need to write the pidfile */
@@ -227,10 +236,12 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
}
#endif
- i_ret = VLC_ENOMEM;
-
if( libvlc_InternalDialogInit( p_libvlc ) != VLC_SUCCESS )
- goto error;
+ {
+ vlc_LogDeinit (p_libvlc);
+ module_EndBank (true);
+ return VLC_ENOMEM;
+ }
if( libvlc_InternalKeystoreInit( p_libvlc ) != VLC_SUCCESS )
msg_Warn( p_libvlc, "memory keystore init failed" );
@@ -356,15 +367,11 @@ dbus_out:
* Initialize hotkey handling
*/
priv->actions = vlc_InitActions( p_libvlc );
- if( !priv->actions )
- goto error;
/*
* Meta data handling
*/
priv->parser = playlist_preparser_New(VLC_OBJECT(p_libvlc));
- if( !priv->parser )
- goto error;
/* Create a variable for showing the fullscreen interface */
var_Create( p_libvlc, "intf-toggle-fscontrol", VLC_VAR_BOOL );
@@ -491,10 +498,6 @@ dbus_out:
}
return VLC_SUCCESS;
-
-error:
- libvlc_InternalCleanup( p_libvlc );
- return i_ret;
}
/**
@@ -507,6 +510,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
/* Ask the interfaces to stop and destroy them */
msg_Dbg( p_libvlc, "removing all interfaces" );
+ libvlc_Quit( p_libvlc );
intf_DestroyAll( p_libvlc );
libvlc_InternalDialogClean( p_libvlc );
More information about the vlc-commits
mailing list