[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54616] trunk/blender/source/blender/ blenlib/intern/string.c: Bug fix #34281

Ton Roosendaal ton at blender.org
Sun Feb 17 19:46:50 CET 2013


Revision: 54616
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54616
Author:   ton
Date:     2013-02-17 18:46:50 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/string.c

Modified: trunk/blender/source/blender/blenlib/intern/string.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string.c	2013-02-17 18:33:10 UTC (rev 54615)
+++ trunk/blender/source/blender/blenlib/intern/string.c	2013-02-17 18:46:50 UTC (rev 54616)
@@ -199,12 +199,15 @@
 	
 	/* 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 




More information about the Bf-blender-cvs mailing list