From 0682ade250a55158b4b5cffbea4de994e373c459 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Jul 2013 21:02:45 +0000 Subject: fix/workaround for crash in ocean modifier when size is zero (causes invalid array index/lookups). --- source/blender/modifiers/intern/MOD_ocean.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 538415b0f87..ecd116a9896 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -426,6 +426,11 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, const float size_co_inv = 1.0f / (omd->size * omd->spatial_size); + /* can happen in when size is small, avoid bad array lookups later and quit now */ + if (!isfinite(size_co_inv)) { + return derivedData; + } + /* update modifier */ if (omd->refresh & MOD_OCEAN_REFRESH_ADD) omd->ocean = BKE_add_ocean(); @@ -531,7 +536,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, } } - #undef OCEAN_CO +#undef OCEAN_CO return dm; } -- cgit v1.2.3