fix for BKE_deform_split_suffix()

- out of bounds read when passing in empty string.
- single character prefix didnt work.
- with no suffix, the string body was truncated.
This commit is contained in:
Campbell Barton
2013-07-27 18:16:22 +00:00
parent 52e54d3c01
commit 684c4cc40d

View File

@@ -537,7 +537,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
body[0] = suf[0] = '\0';
for (i = len - 1; i > 1; i--) {
for (i = len; i > 0; i--) {
if (is_char_sep(string[i])) {
BLI_strncpy(body, string, i + 1);
BLI_strncpy(suf, string + i, (len + 1) - i);
@@ -545,7 +545,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
}
}
BLI_strncpy(body, string, len);
memcpy(body, string, len + 1);
}
/* "a.b.c" -> ("a.", "b.c") */