From: Stuart Buchanan Date: Thu, 15 Jan 2015 21:47:22 +0000 (+0000) Subject: Protect against divide-by-zero error. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4647ce2da5d894aec0fcc5f270dbc1c41b0e2c46;p=simgear.git Protect against divide-by-zero error. Patch from Emilian Huminiuc. --- diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index e18f6f6e..6e7b91af 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -151,8 +151,10 @@ osg::ref_ptr SGNewCloud::genCloud() { float height = min_height + mt_rand(seed) * (max_height - min_height) - min_sprite_height; if (width < 0.0) { width = 0.0; } - if (height < 0.0) { height = 0.0; } + // Protect against divide by 0 issues later when assigning index_y + if (height <= 0.0) { height = 0.01; } + // Determine appropriate shading factors float top_factor = min_top_lighting_factor + mt_rand(seed) * (max_top_lighting_factor - min_top_lighting_factor); float middle_factor = min_middle_lighting_factor + mt_rand(seed) * (max_middle_lighting_factor - min_middle_lighting_factor);