[vlc-devel] commit: assert the vlc object exists in var_* functions, before dereferencing it ( Rafaël Carré )

git version control git at videolan.org
Sun Aug 30 21:32:08 CEST 2009


vlc | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Sun Aug 30 21:23:09 2009 +0200| [d1aea6414f53e763a8c086c0542c0fe975d2cf93] | committer: Rémi Denis-Courmont 

assert the vlc object exists in var_* functions, before dereferencing it

make explicit why using vlm crashes vlc

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d1aea6414f53e763a8c086c0542c0fe975d2cf93
---

 src/misc/variables.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/misc/variables.c b/src/misc/variables.c
index b5ac4bf..964f11d 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -181,6 +181,9 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
     int i_new;
     variable_t *p_var;
     static vlc_list_t dummy_null_list = {0, NULL, NULL};
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -335,6 +338,9 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
 {
     int i_var, i;
     variable_t *p_var;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -408,6 +414,9 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
     int i_var, i;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -677,6 +686,9 @@ int __var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -734,6 +746,9 @@ int __var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
 int __var_Type( vlc_object_t *p_this, const char *psz_name )
 {
     int i_var, i_type;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -760,6 +775,9 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name,
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -815,6 +833,8 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
 int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
                     int expected_type, vlc_value_t *p_val )
 {
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
     int i_var, err = VLC_SUCCESS;
 
@@ -882,6 +902,9 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
     int i_var;
     variable_t *p_var;
     callback_entry_t entry;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     entry.pf_callback = pf_callback;
@@ -922,6 +945,9 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
 #ifndef NDEBUG
     bool b_found_similar = false;
 #endif
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -980,6 +1006,9 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
     int i_var;
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -1159,6 +1188,8 @@ cleanup:
  *****************************************************************************/
 static int GetUnused( vlc_object_t *p_this, const char *psz_name )
 {
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     while( true )
@@ -1501,6 +1532,9 @@ static int TriggerCallback( vlc_object_t *p_this, variable_t **pp_var,
     int i_var;
     int i_entries = (*pp_var)->i_entries;
     callback_entry_t *p_entries = (*pp_var)->p_entries;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     (*pp_var)->b_incallback = true;




More information about the vlc-devel mailing list