Fix T45884: Crash copying keyframes

BLI_str_quoted_substrN could crash if the prefix wasn't found
This commit is contained in:
Campbell Barton 2015-08-24 09:23:24 +10:00
parent 231ee60ab5
commit 4f61de6588
Notes: blender-bot 2023-02-14 08:45:12 +01:00
Referenced by issue #45900, Blender replacing spaces in filename with underscore
Referenced by issue #45884, Blender crashes when copy a of an armature is copied
Referenced by issue #45820, blender animation keyframe copy
1 changed files with 4 additions and 3 deletions

View File

@ -379,12 +379,13 @@ escape_finish:
*/
char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
{
size_t prefixLen = strlen(prefix);
const char *startMatch, *endMatch;
/* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
startMatch = strstr(str, prefix) + prefixLen + 1;
startMatch = strstr(str, prefix);
if (startMatch) {
const size_t prefixLen = strlen(prefix);
startMatch += prefixLen + 1;
/* get the end point (i.e. where the next occurance of " is after the starting point) */
endMatch = startMatch;