[libav-devel] [PATCH] Fix crash when initializing multi-threaded decoding for corrupted file

Måns Rullgård mans at mansr.com
Sat Nov 26 20:01:01 CET 2011


"Ronald S. Bultje" <rsbultje at gmail.com> writes:

> Hi,
>
> 2011/11/26 Måns Rullgård <mans at mansr.com>:
>> Cheng Sun <cheng.sun at ymail.com> writes:
>>
>>> ---
>>>  libavcodec/pthread.c |    3 ++-
>>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
>>> index 3364376..dae28e6 100644
>>> --- a/libavcodec/pthread.c
>>> +++ b/libavcodec/pthread.c
>>> @@ -651,7 +651,8 @@ static void frame_thread_free(AVCodecContext *avctx,
>>> int thread_count)
>>>          pthread_cond_signal(&p->input_cond);
>>>          pthread_mutex_unlock(&p->mutex);
>>>
>>> -        pthread_join(p->thread, NULL);
>>> +        if (p->thread)
>>> +            pthread_join(p->thread, NULL);
>>
>> This is wrong.  pthread_t doesn't have to be a pointer or even a scalar
>> type.  I vaguely recall actually seeing a system where it wasn't, but I
>> can't remember which it might have been.
>
> I'd need to know what system that is so we can fix it appropriately for them.

No, you don't.  Just use some portable way of tracking the status of
threads.  You could for example set a flag on a successful pthread_create()
call.

-- 
Måns Rullgård
mans at mansr.com


More information about the libav-devel mailing list