[vlc-commits] macosx/media library: add missing sanity checks

Felix Paul Kühne git at videolan.org
Thu Apr 30 15:09:43 CEST 2020


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu Apr 30 15:06:30 2020 +0200| [8ae48d5606d413f9c1dfd66a9f6030e386a884e9] | committer: Felix Paul Kühne

macosx/media library: add missing sanity checks

This unbreaks playback if the media library is disabled at runtime.

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

 modules/gui/macosx/library/VLCLibraryDataTypes.m | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index 5aee788748..167ecaf38e 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -187,6 +187,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     vlc_ml_artist_t *p_artist = vlc_ml_get_artist(p_mediaLibrary, artistID);
     VLCMediaLibraryArtist *artist = nil;
     if (p_artist) {
@@ -238,6 +241,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return @[];
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return @[];
+    }
     vlc_ml_media_list_t *p_mediaList = vlc_ml_list_album_tracks(p_mediaLibrary, NULL, _albumID);
     NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_mediaList->i_nb_items];
     for (size_t x = 0; x < p_mediaList->i_nb_items; x++) {
@@ -300,6 +306,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     vlc_ml_media_t *p_mediaItem = vlc_ml_get_media(p_mediaLibrary, libraryID);
     VLCMediaLibraryMediaItem *returnValue = nil;
     if (p_mediaItem) {
@@ -315,6 +324,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     vlc_ml_media_t *p_mediaItem = vlc_ml_get_media_by_mrl(p_mediaLibrary,
                                                           [[url absoluteString] UTF8String]);
     VLCMediaLibraryMediaItem *returnValue = nil;
@@ -331,6 +343,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     if (p_mediaItem != NULL && p_mediaLibrary != NULL) {
         return [self initWithMediaItem:p_mediaItem library:p_mediaLibrary];
     }
@@ -409,6 +424,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     vlc_ml_media_t *p_media = vlc_ml_new_external_media(p_mediaLibrary, urlString.UTF8String);
     if (p_media) {
         self = [self initWithMediaItem:p_media library:p_mediaLibrary];
@@ -429,6 +447,9 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
         return nil;
     }
     vlc_medialibrary_t *p_mediaLibrary = vlc_ml_instance_get(p_intf);
+    if (!p_mediaLibrary) {
+        return nil;
+    }
     vlc_ml_media_t *p_media = vlc_ml_new_stream(p_mediaLibrary, urlString.UTF8String);
     if (p_media) {
         self = [self initWithMediaItem:p_media library:p_mediaLibrary];



More information about the vlc-commits mailing list