Skip to content

macosx: Fix a crash in VLCLibraryHeroView.randomItem

Use of videoCount - 1 without checking videoCount != 0 resulting to a integer underflow when there is no video.

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1462987275 beyond bounds for empty array'
*** First throw call stack:
(
        0   CoreFoundation                      0x0000000180f5c540 __exceptionPreprocess + 176
        1   libobjc.A.dylib                     0x0000000180a4deb4 objc_exception_throw + 60
        2   CoreFoundation                      0x0000000180f859b0 CFArrayApply + 0
        3   libmacosx_plugin.dylib              0x0000000105483c64 -[VLCLibraryHeroView randomItem] + 212
        4   libmacosx_plugin.dylib              0x00000001054840d8 -[VLCLibraryHeroView setOptimalRepresentedItem] + 600
        5   libmacosx_plugin.dylib              0x000000010548454c -[VLCLibraryHeroView newVideosAvailable:] + 72
        6   CoreFoundation                      0x0000000180edc500 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
        7   CoreFoundation                      0x0000000180f7062c ___CFXRegistrationPost_block_invoke + 88
        8   CoreFoundation                      0x0000000180f70574 _CFXRegistrationPost + 440
        9   CoreFoundation                      0x0000000180eab16c _CFXNotificationPost + 764
        10  Foundation                          0x0000000181f9ff50 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
        11  libmacosx_plugin.dylib              0x000000010548ebd4 -[VLCLibraryModelChangeDelegate throttleTimerFired:] + 252
        12  Foundation                          0x000000018202aaf8 __NSFireTimer + 104
        13  CoreFoundation                      0x0000000180f039b0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
        14  CoreFoundation                      0x0000000180f03658 __CFRunLoopDoTimer + 972
        15  CoreFoundation                      0x0000000180f03190 __CFRunLoopDoTimers + 356
        16  CoreFoundation                      0x0000000180ee66d4 __CFRunLoopRun + 1856
        17  CoreFoundation                      0x0000000180ee593c CFRunLoopRunSpecific + 608
        18  HIToolbox                           0x000000018b4ae448 RunCurrentEventLoopInMode + 292
        19  HIToolbox                           0x000000018b4ae284 ReceiveNextEventCommon + 648
        20  HIToolbox                           0x000000018b4adfdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
        21  AppKit                              0x00000001846c4ed0 _DPSNextEvent + 660
        22  AppKit                              0x0000000184eafeec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
        23  AppKit                              0x00000001846b837c -[NSApplication run] + 476
        24  vlc-osx-static                      0x00000001027c72f8 main + 1780
        25  dyld                                0x0000000180a890e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort      ./bin/vlc-osx-static

Merge request reports

Loading