mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
sw_engine mempool: fixed to address a potential memory corruption issue.
The previous memory pool was being shared by both the main and first threads, which could lead to corruption if any threading changes occurred. @Issue: https://github.com/thorvg/thorvg/issues/1370
This commit is contained in:
parent
bf2b348343
commit
7e3380db8b
2 changed files with 5 additions and 5 deletions
|
@ -60,16 +60,16 @@ void mpoolRetStrokeOutline(SwMpool* mpool, unsigned idx)
|
||||||
|
|
||||||
SwMpool* mpoolInit(unsigned threads)
|
SwMpool* mpoolInit(unsigned threads)
|
||||||
{
|
{
|
||||||
if (threads == 0) threads = 1;
|
auto allocSize = threads + 1;
|
||||||
|
|
||||||
auto mpool = static_cast<SwMpool*>(calloc(sizeof(SwMpool), 1));
|
auto mpool = static_cast<SwMpool*>(calloc(sizeof(SwMpool), 1));
|
||||||
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * threads));
|
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
||||||
if (!mpool->outline) goto err;
|
if (!mpool->outline) goto err;
|
||||||
|
|
||||||
mpool->strokeOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * threads));
|
mpool->strokeOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
||||||
if (!mpool->strokeOutline) goto err;
|
if (!mpool->strokeOutline) goto err;
|
||||||
|
|
||||||
mpool->allocSize = threads;
|
mpool->allocSize = allocSize;
|
||||||
|
|
||||||
return mpool;
|
return mpool;
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ struct TaskSchedulerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success && !taskQueues[i].pop(&task)) break;
|
if (!success && !taskQueues[i].pop(&task)) break;
|
||||||
(*task)(i);
|
(*task)(i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue