Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-01-13 13:10:13 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-01-13 13:10:13 +0300
commit9024b6789eb368c0cb4dc05e6659ddca9f362fbd (patch)
tree8f78bd4706cf4ef7eab1f8a0bc101823a8c72838 /source/blender/modifiers/intern/MOD_fluidsim_util.c
parentf373dd6a506223a611ae50c7a8b4b16d7c9ad19d (diff)
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.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluidsim_util.c')
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 1ff997f92d7..7392dfbd7d3 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -169,7 +169,7 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
/* 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 @@ DerivedMesh *fluidsim_read_obj(char *filename)
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");