Fix #124995: Crashes in rendering code due to invalid material indices #125309

Merged
Falk David merged 2 commits from filedescriptor/blender:fix-124995 into main 2024-07-23 14:35:43 +02:00

2 Commits

Author SHA1 Message Date
bad12765f1 Update comment 2024-07-23 13:50:54 +02:00
2d56f4ad16 Fix #124995: Crashes in rendering code due to invalid material indices
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
The issue was that some `material_index` were `-1`. This meant that
the rendering code was accessing out-of-bounds memory to read
from the material pool.

The fix adds an assert to the `gpencil_material_resources_get` and
clamps the `material_index` to >= 0 to ensure that the material is
valid. It also changes the default read value for the material indices
in `create_curves_outline` and `retrieve_visible_strokes` to be 0
instead of -1.
2024-07-23 13:38:20 +02:00