diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-08-24 02:23:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-08-24 02:29:00 +0300 |
commit | 4f61de65883959f62e94bd5f4065cd04f0b9595f (patch) | |
tree | cd847abae433010848551e4bef4d29b85c0a2bdd /source/blender | |
parent | 231ee60ab5373bb2e5676fc4f5c6dea476fc1d42 (diff) |
Fix T45884: Crash copying keyframes
BLI_str_quoted_substrN could crash if the prefix wasn't found
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 6d75f7c4131..6cc00fc60ee 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -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; |