Fix for 2.99 only #6157
See commit text.
The fixed crash is low impact "just don't do that". But fix it and refactor before coming changes for binding resource SF-BRUSH etc.
Needs port to 2.10, but Kevin has already suggested a smaller fix for 2.10