Fix #128257: Crash when using Set Vertex Colors with no brush

The issue is due to a null pointer dereference in the call to
`IMB_colormanagement_srgb_to_scene_linear_v3` in
`vpaint_get_current_col` in `paint_vertex.cc`.
`BKE_paint_brush_for_read` returns a null pointer and as a result
`brush_color` points to the zero page, thus causing a null pointer
dereference and hence the access violation exception.

Normally, users should not be able to have no brush selected inside
vertex paint mode. Instead of adding null checks everywhere, this
commit protects against this case by switching the poll method to
check for a brush before allowing execution.

Pull Request: https://projects.blender.org/blender/blender/pulls/128260
This commit is contained in:
notrudyyy 2024-10-01 00:04:53 +02:00 committed by Sean Kim
parent 44fbd69317
commit 8d11882d07

View file

@ -2320,7 +2320,7 @@ void PAINT_OT_vertex_color_set(wmOperatorType *ot)
ot->description = "Fill the active vertex color layer with the current paint color";
ot->exec = vertex_color_set_exec;
ot->poll = vertex_paint_mode_poll;
ot->poll = vertex_paint_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;