[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34294] trunk/blender/source/blender/ modifiers/intern/MOD_fluidsim_util.c: Possible fix for [#24924] crash-Fluids

Janne Karhu jhkarh at gmail.com
Thu Jan 13 11:10:14 CET 2011


Revision: 34294
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34294
Author:   jhk
Date:     2011-01-13 10:10:13 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Possible fix for [#24924] crash-Fluids
* In some rare cases gzread has problems with the fluid files. This could be minor file corruption or some strange thread issue, but checking the amount of read bytes always after read seems to give a graceful way out.

Modified Paths:
--------------
    trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c

Modified: trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c	2011-01-13 07:25:18 UTC (rev 34293)
+++ trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c	2011-01-13 10:10:13 UTC (rev 34294)
@@ -169,7 +169,7 @@
 /* read .bobj.gz file into a fluidsimDerivedMesh struct */
 DerivedMesh *fluidsim_read_obj(char *filename)
 {
-	int wri,i,j;
+	int wri = 0,i,j;
 	float wrf;
 	int gotBytes;
 	gzFile gzf;
@@ -193,28 +193,30 @@
 	numverts = wri;
 
 	// skip verts
-	for(i=0; i<numverts*3; i++)
+	for(i=0; i<numverts*3 && gotBytes; i++)
 	{
 		gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
 	}
 
 	// read number of normals
-	gotBytes = gzread(gzf, &wri, sizeof(wri));
+	if(gotBytes)
+		gotBytes = gzread(gzf, &wri, sizeof(wri));
 
 	// skip normals
-	for(i=0; i<numverts*3; i++)
+	for(i=0; i<numverts*3 && gotBytes; i++)
 	{
 		gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
 	}
 
 	/* get no. of triangles */
-	gotBytes = gzread(gzf, &wri, sizeof(wri));
+	if(gotBytes)
+		gotBytes = gzread(gzf, &wri, sizeof(wri));
 	numfaces = wri;
 
 	gzclose( gzf );
 	// ------------------------------------------------
 
-	if(!numfaces || !numverts)
+	if(!numfaces || !numverts || !gotBytes)
 		return NULL;
 
 	gzf = gzopen(filename, "rb");




More information about the Bf-blender-cvs mailing list