From 029686a2fd7819ef0047dc4dc566d4f08d647624 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 17 Feb 2013 18:46:50 +0000 Subject: [PATCH] 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. --- source/blender/blenlib/intern/string.c | 15 +++++++++------ 1 file 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