From f3e066cce04bf07e4fcc9e9a4b2662691936a9b3 Mon Sep 17 00:00:00 2001 From: Ron Haertel Date: Sat, 24 Dec 2016 14:00:37 -0500 Subject: [PATCH] Bug fix for bug 1920 In pt_lights.cxx in SGLightFactory::getOdal, at segment "centerline lights", the decrement loop index i is initialized with lights.getNumLights(), then is used at lights.getLight. (ERROR) The function getNumLights is set to the size of the vector which is one more than the max index refernce. This restores the behavior that was in place before commit 8ddb99f62ff033e7e05c32e1755a62bb7adbb712 --- simgear/scene/tgdb/pt_lights.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index cd71fa98..7c40d313 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -403,7 +403,7 @@ SGLightFactory::getOdal(const SGLightBin& lights, const SGReaderWriterOptions* o Effect* effect = getLightEffect(10.0f, osg::Vec3(1.0, 0.0001, 0.00000001), 6.0, 10.0, false, options); // centerline lights - for (int i = lights.getNumLights(); i > 1; --i) { + for (int i = lights.getNumLights() - 1; i >= 2; i--) { EffectGeode* egeode = new EffectGeode; egeode->setEffect(effect); egeode->addDrawable(getLightDrawable(lights.getLight(i)));