]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programdata.cpp
Avoid memory leak if an invalid uniform name is given
[libs/gl.git] / source / programdata.cpp
index 615da767fedefca62eebd06b68fce816aa166ad2..8a10f59c0c73beb5d5406816b0d63987fb087558 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/gl/extensions/arb_direct_state_access.h>
 #include "buffer.h"
 #include "color.h"
 #include "error.h"
@@ -64,7 +65,10 @@ ProgramData::~ProgramData()
 void ProgramData::uniform(const string &name, Uniform *uni)
 {
        if(name[name.size()-1]==']')
+       {
+               delete uni;
                throw invalid_argument("ProgramData::uniform");
+       }
 
        SlotMap::iterator i = uniform_slots.find(name);
        if(i!=uniform_slots.end())
@@ -375,7 +379,7 @@ void ProgramData::apply() const
 
                /* If any blocks stored in the buffer were updated, bind the buffer here
                to avoid state thrashing. */
-               if(buffered_blocks_updated)
+               if(buffered_blocks_updated && !ARB_direct_state_access)
                        buffer->bind();
        }