Fix T80516: Hook modifier crashes without vertex group data

Checks for existence of a vertex group must check the array isn't NULL.

Regression in c1386795a9.
This commit is contained in:
Campbell Barton 2020-09-10 17:58:05 +10:00
parent 92a1b3f750
commit a0f41ba8a2
Notes: blender-bot 2023-02-13 21:18:00 +01:00
Referenced by issue #80516, Hook Modifier Crash Blender
Referenced by issue #80396, Potential candidates for corrective releases
1 changed files with 13 additions and 4 deletions

View File

@ -313,10 +313,19 @@ static void deformVerts_do(HookModifierData *hmd,
MOD_get_vgroup(ob, mesh, hmd->name, &dvert, &hd.defgrp_index);
int cd_dvert_offset = -1;
if ((em != NULL) && (hd.defgrp_index != -1)) {
cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
if (cd_dvert_offset == -1) {
hd.defgrp_index = -1;
if (hd.defgrp_index != -1) {
/* Edit-mesh. */
if (em != NULL) {
cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
if (cd_dvert_offset == -1) {
hd.defgrp_index = -1;
}
}
else {
/* Regular mesh. */
if (dvert == NULL) {
hd.defgrp_index = -1;
}
}
}