sw_engine: fix an invalid memory access.

the surface and mesh data can be missed by an invalid condition.
this fixes an invalid memory access problem.

Issue: https://github.com/thorvg/thorvg/issues/1671
This commit is contained in:
Hermet Park 2023-09-26 17:21:42 +09:00 committed by Hermet Park
parent 92b6f9dc48
commit 51c3a8912c
2 changed files with 3 additions and 4 deletions

View file

@ -773,10 +773,8 @@ RenderData SwRenderer::prepare(Surface* surface, const RenderMesh* mesh, RenderD
//prepare task
auto task = static_cast<SwImageTask*>(data);
if (!task) task = new SwImageTask;
if (flags & RenderUpdateFlag::Image) {
task->source = surface;
task->mesh = mesh;
}
task->source = surface;
task->mesh = mesh;
return prepareCommon(task, transform, clips, opacity, flags);
}

View file

@ -13,6 +13,7 @@ exe_suffix = 'js'
[built-in options]
cpp_args = ['-Wshift-negative-value', '-flto', '-Os', '-fno-exceptions']
cpp_link_args = ['-Wshift-negative-value', '-flto', '-Os', '-fno-exceptions', '--bind', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sFORCE_FILESYSTEM=1']
#cpp_link_args = ['-Wshift-negative-value', '-flto', '-Os', '-fno-exceptions', '--bind', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sFORCE_FILESYSTEM=1', '-g'] //enable g flag for wasm debugging
[host_machine]
system = 'emscripten'