]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
Introduce realloc_or_free() to src/*, and add assert() to mark unhandled ENOMEM error...
[vlc] / src / misc / variables.c
index 714ed58a09ebd397dbfc956137e123e35ee1ee66..23cd3d943c4596465f5e63b129f46e303e43b30f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <vlc_common.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 #include "variables.h"
 
 #include "libvlc.h"
@@ -217,8 +218,9 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
 
     if( (p_priv->i_vars & 15) == 15 )
     {
-        p_priv->p_vars = realloc( p_priv->p_vars,
+        p_priv->p_vars = realloc_or_free( p_priv->p_vars,
                                   (p_priv->i_vars+17) * sizeof(variable_t) );
+        assert( p_priv->p_vars );
     }
 
     memmove( p_priv->p_vars + i_new + 1,
@@ -389,8 +391,10 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
 
     if( (p_priv->i_vars & 15) == 0 )
     {
-        p_priv->p_vars = realloc( p_priv->p_vars,
-                          (p_priv->i_vars) * sizeof( variable_t ) );
+        variable_t *p_vars = realloc( p_priv->p_vars,
+                                    (p_priv->i_vars) * sizeof( variable_t ) );
+        if( p_vars )
+            p_priv->p_vars = p_vars;
     }
 
     p_priv->i_vars--;