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. Pull Request: https://projects.blender.org/blender/blender/pulls/125309