]> git.tdb.fi Git - libs/gl.git/commitdiff
Check range when attaching Lights to a Lighting
authorMikko Rasa <tdb@tdb.fi>
Thu, 28 Nov 2013 12:24:11 +0000 (14:24 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 28 Nov 2013 12:24:11 +0000 (14:24 +0200)
source/lighting.cpp

index aae5d331384919e0af9f8523523eda56a5273bab..517530a2f128854f964f673411f11eedfc97df87 100644 (file)
@@ -1,7 +1,11 @@
+#include <stdexcept>
 #include "light.h"
 #include "lighting.h"
+#include "lightunit.h"
 #include "misc.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GL {
 
@@ -16,6 +20,9 @@ void Lighting::set_ambient(const Color &a)
 
 void Lighting::attach(unsigned i, const Light &l)
 {
+       if(i>=LightUnit::get_n_units())
+               throw out_of_range("Lighting::attach");
+
        if(i>=lights.size())
                lights.resize(i+1);