[vlc-commits] [Git][videolan/vlc][master] macosx: Avoid possible crashes from null pointers being function parameters in VLCLibraryDataTypes
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Sep 14 13:52:35 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
24779e2e by Claudio Cambra at 2022-09-14T13:23:02+00:00
macosx: Avoid possible crashes from null pointers being function parameters in VLCLibraryDataTypes
Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/VLCLibraryDataTypes.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -561,12 +561,12 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
+ (nullable instancetype)mediaItemForURL:(NSURL *)url
{
- if(url == nil) {
+ if (url == nil) {
return nil;
}
vlc_medialibrary_t *p_mediaLibrary = getMediaLibrary();
- if(!p_mediaLibrary) {
+ if (!p_mediaLibrary) {
return nil;
}
vlc_ml_media_t *p_mediaItem = vlc_ml_get_media_by_mrl(p_mediaLibrary,
@@ -580,8 +580,12 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (nullable instancetype)initWithMediaItem:(struct vlc_ml_media_t *)p_mediaItem
{
+ if (p_mediaItem == NULL) {
+ return nil;
+ }
+
vlc_medialibrary_t *p_mediaLibrary = getMediaLibrary();
- if(!p_mediaLibrary) {
+ if (!p_mediaLibrary) {
return nil;
}
if (p_mediaItem != NULL && p_mediaLibrary != NULL) {
@@ -593,7 +597,7 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (instancetype)initWithMediaItem:(struct vlc_ml_media_t *)p_mediaItem library:(vlc_medialibrary_t *)p_mediaLibrary
{
self = [super init];
- if (self) {
+ if (self && p_mediaItem != NULL && p_mediaLibrary != NULL) {
_p_mediaLibrary = p_mediaLibrary;
_libraryID = p_mediaItem->i_id;
_mediaType = p_mediaItem->i_type;
@@ -653,13 +657,17 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (nullable instancetype)initWithExternalURL:(NSURL *)url
{
+ if (url == nil) {
+ return nil;
+ }
+
NSString *urlString = url.absoluteString;
if (!urlString) {
return self;
}
vlc_medialibrary_t *p_mediaLibrary = getMediaLibrary();
- if(!p_mediaLibrary) {
+ if (!p_mediaLibrary) {
return nil;
}
vlc_ml_media_t *p_media = vlc_ml_new_external_media(p_mediaLibrary, urlString.UTF8String);
@@ -672,13 +680,17 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (nullable instancetype)initWithStreamURL:(NSURL *)url
{
+ if (url == nil) {
+ return nil;
+ }
+
NSString *urlString = url.absoluteString;
if (!urlString) {
return self;
}
vlc_medialibrary_t *p_mediaLibrary = getMediaLibrary();
- if(!p_mediaLibrary) {
+ if (!p_mediaLibrary) {
return nil;
}
vlc_ml_media_t *p_media = vlc_ml_new_stream(p_mediaLibrary, urlString.UTF8String);
@@ -691,6 +703,10 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
+ if (aDecoder == nil) {
+ return nil;
+ }
+
int64_t libraryID = [aDecoder decodeInt64ForKey:VLCMediaLibraryMediaItemLibraryID];
self = [VLCMediaLibraryMediaItem mediaItemForLibraryID:libraryID];
return self;
@@ -698,6 +714,10 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
- (void)encodeWithCoder:(NSCoder *)aCoder
{
+ if (aCoder == nil) {
+ return;
+ }
+
[aCoder encodeInt64:_libraryID forKey:VLCMediaLibraryMediaItemLibraryID];
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/24779e2e4d49f5543d5b3867b848cf88bfc35613
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/24779e2e4d49f5543d5b3867b848cf88bfc35613
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