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:
Hermet Park 2023-04-24 17:18:32 +09:00
parent bf2b348343
commit 7e3380db8b
2 changed files with 5 additions and 5 deletions

View file

@ -60,16 +60,16 @@ void mpoolRetStrokeOutline(SwMpool* mpool, unsigned idx)
SwMpool* mpoolInit(unsigned threads)
{
if (threads == 0) threads = 1;
auto allocSize = threads + 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;
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;
mpool->allocSize = threads;
mpool->allocSize = allocSize;
return mpool;

View file

@ -135,7 +135,7 @@ struct TaskSchedulerImpl
}
if (!success && !taskQueues[i].pop(&task)) break;
(*task)(i);
(*task)(i + 1);
}
}