Skip to content

VLCMediaList::mediaListItemRemoved Bug

Real-life reference: https://rink.hockeyapp.net/manage/apps/194470/app_versions/106/crash_reasons/211622999 as pointed by @caro

I was able to reproduce the above crash with the following test

func testDeleteMedia() throws {
    let videos = [Video.test1, Video.test1]
    let source = videos.map{ VLCMedia(path: $0.path) }
    let mediaList = try XCTAssertNotNilAndUnwrap(VLCMediaList(array: source))
    let tests: [(deleteIdx: UInt, expected: [Int], count: Int)] = [
        (0, [-1,0], 1),
        (0, [-1,-1], 0)
    ]
        
    for (i, test) in tests.enumerated() {
        mediaList.removeMedia(at: test.deleteIdx)
        
        let order = source.map { mediaList.index(of: $0) }
        XCTAssertEqual(order, test.expected)
        XCTAssertEqual(mediaList.count, test.count)
    }
}

With the current version, above test crashes with the message

'NSRangeException', reason: '*** -[__NSArrayM removeObjectsInRange:]: range {0, 1} extends beyond bounds for empty array'

Edited by Mike JS. Choi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information