[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28726] trunk/blender/source/blender: fix for crash reading pointcache, was reading over the buffer size, use lzo1x_decompress_safe rather then lzo1x_decompress

Campbell Barton ideasman42 at gmail.com
Tue May 11 21:37:19 CEST 2010


Revision: 28726
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28726
Author:   campbellbarton
Date:     2010-05-11 21:37:17 +0200 (Tue, 11 May 2010)

Log Message:
-----------
fix for crash reading pointcache, was reading over the buffer size, use lzo1x_decompress_safe rather then lzo1x_decompress

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/makesrna/intern/rna_object_force.c

Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-05-11 14:25:48 UTC (rev 28725)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-05-11 19:37:17 UTC (rev 28726)
@@ -812,23 +812,27 @@
 	ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
 	if(compressed) {
 		ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int));
-		in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
-		ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
-
+		if(in_len==0) {
+			/* do nothing */
+		}
+		else {
+			in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
+			ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
 #ifdef WITH_LZO
-		if(compressed == 1)
-				r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
+			if(compressed == 1)
+				r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
 #endif
 #ifdef WITH_LZMA
-		if(compressed == 2)
-		{
-			size_t leni = in_len, leno = out_len;
-			ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int));
-			ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
-			r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
+			if(compressed == 2)
+			{
+				size_t leni = in_len, leno = out_len;
+				ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int));
+				ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
+				r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
+			}
+#endif
+			MEM_freeN(in);
 		}
-#endif
-		MEM_freeN(in);
 	}
 	else {
 		ptcache_file_read(pf, result, len, sizeof(unsigned char));

Modified: trunk/blender/source/blender/makesrna/intern/rna_object_force.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object_force.c	2010-05-11 14:25:48 UTC (rev 28725)
+++ trunk/blender/source/blender/makesrna/intern/rna_object_force.c	2010-05-11 19:37:17 UTC (rev 28726)
@@ -749,7 +749,7 @@
     
 	prop= RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTCACHE_IGNORE_LIBPATH);
-	RNA_def_property_ui_text(prop, "Library Path", "Use this files path when library linked indo another file.");
+	RNA_def_property_ui_text(prop, "Library Path", "Use this files path when library linked into another file.");
 	RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
 
 	prop= RNA_def_property(srna, "point_cache_list", PROP_COLLECTION, PROP_NONE);





More information about the Bf-blender-cvs mailing list