[vlc-commits] [Git][videolan/vlc][master] macosx: Prevent concurrent modification of child nodes of a directory input node

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jun 24 09:21:11 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ca03fe04 by Claudio Cambra at 2025-06-24T08:54:27+00:00
macosx: Prevent concurrent modification of child nodes of a directory input node

Fixes crash from nodes being deallocated during concurrent access

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/media-source/VLCMediaSource.m


Changes:

=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.m
=====================================
@@ -31,6 +31,7 @@
     vlc_preparser_t *_p_preparser;
     vlc_media_source_t *_p_mediaSource;
     vlc_media_tree_listener_id *_p_treeListenerID;
+    NSLock *_generateChildNodesLock;
 }
 @end
 
@@ -105,6 +106,7 @@ static const char *const myFoldersDescription = "My Folders";
 {
     self = [super init];
     if (self) {
+        _generateChildNodesLock = [[NSLock alloc] init];
         _respondsToDiskChanges = NO;
         _p_preparser = p_preparser;
         
@@ -133,6 +135,7 @@ static const char *const myFoldersDescription = "My Folders";
 {
     self = [super init];
     if (self && p_mediaSource != NULL) {
+        _generateChildNodesLock = [[NSLock alloc] init];
         _respondsToDiskChanges = NO;
         _p_preparser = p_preparser;
         _p_mediaSource = p_mediaSource;
@@ -150,6 +153,7 @@ static const char *const myFoldersDescription = "My Folders";
 {
     self = [super init];
     if (self) {
+        _generateChildNodesLock = [[NSLock alloc] init];
         _p_preparser = p_preparser;
 
          _p_mediaSource = malloc(sizeof(vlc_media_source_t));
@@ -219,6 +223,7 @@ static const char *const myFoldersDescription = "My Folders";
 {
     self = [super init];
     if (self) {
+        _generateChildNodesLock = [[NSLock alloc] init];
         _p_preparser = p_preparser;
 
          _p_mediaSource = malloc(sizeof(vlc_media_source_t));
@@ -410,6 +415,8 @@ static const char *const myFoldersDescription = "My Folders";
                                         withUrl:(NSURL *)directoryUrl
 {
     NSParameterAssert(directoryNode != NULL && directoryUrl != nil);
+    [_generateChildNodesLock lock];
+
     if (self.willStartGeneratingChildNodesForNodeHandler) {
         self.willStartGeneratingChildNodesForNodeHandler(directoryNode);
     }
@@ -485,6 +492,7 @@ static const char *const myFoldersDescription = "My Folders";
     if (self.didFinishGeneratingChildNodesForNodeHandler) {
         self.didFinishGeneratingChildNodesForNodeHandler(directoryNode);
     }
+    [_generateChildNodesLock unlock];
 
     return nil;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ca03fe048ed7591f1eca20e55dbcfcae281f95bc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ca03fe048ed7591f1eca20e55dbcfcae281f95bc
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list