diff options
author | Ton Roosendaal <ton@blender.org> | 2013-02-17 22:46:50 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2013-02-17 22:46:50 +0400 |
commit | 029686a2fd7819ef0047dc4dc566d4f08d647624 (patch) | |
tree | 48098a42e494072ae131ef6cefad9dcf33e3cf68 /source | |
parent | ee64cbaf3916002845af17e153855ca125f67bd7 (diff) |
Bug fix #34281
The RNA path interpretor code was using a function to get the portion between quotes,
this function was not even checking if there *are* quotes at all! Causing bad
memory allocs or crashes.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 28fdf7b61db..3500f3f1805 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -199,12 +199,15 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict /* 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; - - /* get the end point (i.e. where the next occurance of " is after the starting point) */ - endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ - - /* return the slice indicated */ - return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); + if (startMatch) { + /* get the end point (i.e. where the next occurance of " is after the starting point) */ + endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ + + if (endMatch) + /* return the slice indicated */ + return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); + } + return BLI_strdupn("", 0); } /* Replaces all occurrences of oldText with newText in str, returning a new string that doesn't |