Fix bone "auto-name by axis" failure to clip long names

Failure to clip automatic-names meant named could end with a "." for e.g.

Error in [0] meant the clipped text was copied then
immediately overwritten.

[0]: 354e6b9c18
This commit is contained in:
Campbell Barton 2022-04-26 13:46:04 +10:00
parent 3221766820
commit 07e2bd443e
1 changed files with 3 additions and 5 deletions

View File

@ -813,11 +813,9 @@ bool bone_autoside_name(
}
}
if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */
strncpy(name, basename, len - strlen(extension));
}
BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension);
/* Subtract 1 from #MAXBONENAME for the null byte. Add 1 to the extension for the '.' */
const int basename_maxlen = (MAXBONENAME - 1) - (1 + strlen(extension));
BLI_snprintf(name, MAXBONENAME, "%.*s.%s", basename_maxlen, basename, extension);
return true;
}