• Alexander Strange's avatar
    Fix crash on close when decoding a single-frame h264 file with 3+ threads · d812c6f8
    Alexander Strange authored
    Problematic code path:
    1. sps_buffers[0] is allocated in the first thread's codec context when the
    decoder is opened.
    2. The first thread context is memcpy'd to the other threads by frame_thread_init().
    3. The first thread is closed and its sps_buffers[0] is freed.
    4. The third thread is closed.
    Because it never got to decode a frame, update_thread_context was never called,
    and sps_buffers[0] still contained the first thread's pointer.
    
    Fixed by not trying to free sps/pps buffers if the thread wasn't initialized.
    I didn't properly consider this when designing it but this seems to be the
    best approach anyway.
    
    Fixes still2.mp4 crash from Chromium
    d812c6f8
h264.c 138 KB