Commit e5f21614 authored by Rémi Duraffort's avatar Rémi Duraffort

Fix memleaks.

parent f2600dd0
...@@ -71,7 +71,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -71,7 +71,7 @@ static int Open( vlc_object_t *p_this )
DBusConnection *p_connection; DBusConnection *p_connection;
probe_sys_t *p_sys; probe_sys_t *p_sys;
p_probe->p_sys = p_sys = (probe_sys_t*)malloc( sizeof( probe_sys_t ) ); p_probe->p_sys = p_sys = malloc( sizeof( probe_sys_t ) );
p_probe->p_sys->i_devices = 0; p_probe->p_sys->i_devices = 0;
p_probe->p_sys->pp_devices = NULL; p_probe->p_sys->pp_devices = NULL;
...@@ -83,28 +83,29 @@ static int Open( vlc_object_t *p_this ) ...@@ -83,28 +83,29 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_ctx ) if( !p_sys->p_ctx )
{ {
msg_Err( p_probe, "unable to create HAL context") ; msg_Err( p_probe, "unable to create HAL context") ;
free( p_probe->p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error ); p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error );
if( dbus_error_is_set( &dbus_error ) ) if( dbus_error_is_set( &dbus_error ) )
{ {
msg_Err( p_probe, "unable to connect to DBUS: %s", dbus_error.message ); msg_Err( p_probe, "unable to connect to DBUS: %s", dbus_error.message );
dbus_error_free( &dbus_error ); goto error;
free( p_probe->p_sys );
return VLC_EGENERIC;
} }
p_sys->p_connection = p_connection; p_sys->p_connection = p_connection;
libhal_ctx_set_dbus_connection( p_probe->p_sys->p_ctx, p_connection ); libhal_ctx_set_dbus_connection( p_sys->p_ctx, p_connection );
if( !libhal_ctx_init( p_probe->p_sys->p_ctx, &dbus_error ) ) if( !libhal_ctx_init( p_sys->p_ctx, &dbus_error ) )
{ {
msg_Err( p_probe, "hal not available : %s", dbus_error.message ); msg_Err( p_probe, "hal not available : %s", dbus_error.message );
dbus_connection_unref( p_connection ); dbus_connection_unref( p_connection );
goto error;
}
return VLC_SUCCESS;
error:
dbus_error_free( &dbus_error ); dbus_error_free( &dbus_error );
libhal_ctx_free( p_sys->p_ctx );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
}
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -115,6 +116,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -115,6 +116,7 @@ static void Close( vlc_object_t *p_this )
device_probe_t *p_probe = (device_probe_t *) p_this; device_probe_t *p_probe = (device_probe_t *) p_this;
probe_sys_t *p_sys = p_probe->p_sys; probe_sys_t *p_sys = p_probe->p_sys;
dbus_connection_unref( p_sys->p_connection ); dbus_connection_unref( p_sys->p_connection );
libhal_ctx_free( p_sys->p_ctx );
free( p_sys ); free( p_sys );
} }
#if 0 #if 0
......
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