summaryrefslogtreecommitdiff
path: root/libavcodec/w32thread.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-11-20 21:08:26 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-11-20 21:08:26 +0000
commit9fe08942102ecd2dda0d6751b3c7d9f736cc4ee3 (patch)
treeb5e0c38ca55ce32deabe1eed6b3afabc0f14eb51 /libavcodec/w32thread.c
parent1b88277bd9c2d2c55b696cd6679ae864473b1d72 (diff)
downloadffmpeg-9fe08942102ecd2dda0d6751b3c7d9f736cc4ee3.tar.gz
In win32 thread implementation do not access jobnr if the thread is asked
to terminate, jobnr it does not point to a valid location in that case. Originally committed as revision 20565 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/w32thread.c')
-rw-r--r--libavcodec/w32thread.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c
index 4b444b4111..bae09704a8 100644
--- a/libavcodec/w32thread.c
+++ b/libavcodec/w32thread.c
@@ -48,16 +48,17 @@ static unsigned WINAPI attribute_align_arg thread_func(void *v){
int ret, jobnr;
//printf("thread_func %X enter wait\n", (int)v); fflush(stdout);
WaitForSingleObject(c->work_sem, INFINITE);
+ // avoid trying to access jobnr if we should quit
+ if (!c->func && !c->func2)
+ break;
WaitForSingleObject(c->job_sem, INFINITE);
jobnr = (*c->jobnr)++;
ReleaseSemaphore(c->job_sem, 1, 0);
//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
if(c->func)
ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize);
- else if (c->func2)
- ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
else
- return 0;
+ ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
if (c->ret)
c->ret[jobnr] = ret;
//printf("thread_func %X signal complete\n", (int)v); fflush(stdout);