]> git.sesse.net Git - vlc/blobdiff - src/network/acl.c
Fix race condition if multiple threads delete the same HTTP host
[vlc] / src / network / acl.c
index 47b331865df4d9830a6bd96642b7d7fa20326ce9..89c33353c721792c9141d7f2ef47106a596cb74d 100644 (file)
@@ -28,7 +28,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include <ctype.h>
 #include <vlc_acl.h>
@@ -189,9 +189,6 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len,
 
         if( i_len > 128 )
             i_len = 128;
-        else
-        if( i_len < 0 )
-            i_len = 0;
     }
     else
         i_len = 128; /* ACL_AddHost */
@@ -221,7 +218,7 @@ vlc_acl_t *__ACL_Create( vlc_object_t *p_this, bool b_allow )
     if( p_acl == NULL )
         return NULL;
 
-    vlc_object_yield( p_this );
+    vlc_object_hold( p_this );
     p_acl->p_owner = p_this;
     p_acl->i_size = 0;
     p_acl->p_entries = NULL;
@@ -267,7 +264,7 @@ vlc_acl_t *__ACL_Duplicate( vlc_object_t *p_this, const vlc_acl_t *p_acl )
     else
         p_dupacl->p_entries = NULL;
 
-    vlc_object_yield( p_this );
+    vlc_object_hold( p_this );
     p_dupacl->p_owner = p_this;
     p_dupacl->i_size = p_acl->i_size;
     p_dupacl->b_allow_default = p_acl->b_allow_default;
@@ -283,9 +280,7 @@ void ACL_Destroy( vlc_acl_t *p_acl )
 {
     if( p_acl != NULL )
     {
-        if( p_acl->p_entries != NULL )
-            free( p_acl->p_entries );
-
+        free( p_acl->p_entries );
         vlc_object_release( p_acl->p_owner );
         free( p_acl );
     }
@@ -380,7 +375,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
             : ACL_AddHost( p_acl, psz_ip, true ) )
         {
             msg_Err( p_acl->p_owner, "cannot add ACL from %s", psz_path );
-            goto error;
+            continue;
         }
     }