[vlc-commits] [Git][videolan/vlc][master] macosx: prevent crash when editing stale bookmark row
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Aug 9 06:57:24 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
ddd289a5 by Serhii Bykov at 2026-08-09T06:15:23+00:00
macosx: prevent crash when editing stale bookmark row
- - - - -
3 changed files:
- modules/gui/macosx/panels/VLCBookmarksWindowController.m
- modules/gui/macosx/panels/bookmarks/VLCBookmarksTableViewDataSource.h
- modules/gui/macosx/panels/bookmarks/VLCBookmarksTableViewDataSource.m
Changes:
=====================================
modules/gui/macosx/panels/VLCBookmarksWindowController.m
=====================================
@@ -145,6 +145,10 @@
}
VLCBookmark * const bookmark = [_tableViewDataSource bookmarkForRow:selectedRow];
+ if (bookmark == nil) {
+ return;
+ }
+
vlc_tick_t bookmarkTime = VLC_TICK_FROM_MS(bookmark.bookmarkTime);
VLCPlayerController * const playerController = VLCMain.sharedInstance.playQueueController.playerController;
@@ -159,6 +163,10 @@
}
VLCBookmark * const bookmark = [_tableViewDataSource bookmarkForRow:selectedRow];
+ if (bookmark == nil) {
+ return;
+ }
+
[_tableViewDataSource removeBookmark:bookmark];
}
=====================================
modules/gui/macosx/panels/bookmarks/VLCBookmarksTableViewDataSource.h
=====================================
@@ -47,7 +47,7 @@ extern NSString * const VLCBookmarksTableViewTimeTableColumnIdentifier;
- (void)clearBookmarks;
- (void)updateBookmarks;
-- (VLCBookmark *)bookmarkForRow:(NSInteger)row;
+- (nullable VLCBookmark *)bookmarkForRow:(NSInteger)row;
@end
=====================================
modules/gui/macosx/panels/bookmarks/VLCBookmarksTableViewDataSource.m
=====================================
@@ -179,10 +179,13 @@ static void bookmarksLibraryCallback(void *p_data, const vlc_ml_event_t *p_event
return _bookmarks.count;
}
-- (VLCBookmark *)bookmarkForRow:(NSInteger)row
+- (nullable VLCBookmark *)bookmarkForRow:(NSInteger)row
{
- NSParameterAssert(row >= 0 || (NSUInteger)row < _bookmarks.count);
- return [_bookmarks objectAtIndex:row];
+ if (row < 0 || (NSUInteger)row >= _bookmarks.count) {
+ return nil;
+ }
+
+ return _bookmarks[(NSUInteger)row];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
@@ -192,7 +195,9 @@ static void bookmarksLibraryCallback(void *p_data, const vlc_ml_event_t *p_event
}
VLCBookmark * const bookmark = [self bookmarkForRow:row];
- NSAssert(bookmark != nil, @"Should be a valid bookmark");
+ if (bookmark == nil) {
+ return @"";
+ }
NSString * const identifier = [tableColumn identifier];
@@ -213,6 +218,10 @@ static void bookmarksLibraryCallback(void *p_data, const vlc_ml_event_t *p_event
row:(NSInteger)row
{
VLCBookmark * const bookmark = [self bookmarkForRow:row];
+ if (bookmark == nil) {
+ return;
+ }
+
VLCBookmark * const originalBookmark = [bookmark copy];
NSString * const columnIdentifier = tableColumn.identifier;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ddd289a53dce75a884549713801d86c71c3b2dcd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ddd289a53dce75a884549713801d86c71c3b2dcd
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list