Fix memory corruption in shader materials.
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Mon, 18 Aug 2014 07:31:08 +0000 (09:31 +0200)
committerGunnar Sletta <gunnar.sletta@jollamobile.com>
Tue, 19 Aug 2014 07:50:53 +0000 (09:50 +0200)
Change ee616b3905106a3eedef9ee964ab283ef45c7dbc accidentally
removed the member variable used to refcount the attribute
names. This resulted in the names being deleted and the
stored const char *'s to become invalid. Add it back.

Change-Id: Ie33f75cd76085283a5ee685602e023bb3c42c896
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
src/quick/items/qquickshadereffectnode.cpp

index df1fcea..cefb006 100644 (file)
@@ -65,6 +65,7 @@ protected:
     virtual const char *fragmentShader() const;
 
     const QQuickShaderEffectMaterialKey m_key;
+    QVector<QByteArray> m_attributes;
     QVector<const char *> m_attributeNames;
     QString m_log;
     bool m_compiled;
@@ -75,11 +76,12 @@ protected:
 
 QQuickCustomMaterialShader::QQuickCustomMaterialShader(const QQuickShaderEffectMaterialKey &key, const QVector<QByteArray> &attributes)
     : m_key(key)
+    , m_attributes(attributes)
     , m_compiled(false)
     , m_initialized(false)
 {
-    for (int i = 0; i < attributes.count(); ++i)
-        m_attributeNames.append(attributes.at(i).constData());
+    for (int i = 0; i < m_attributes.count(); ++i)
+        m_attributeNames.append(m_attributes.at(i).constData());
     m_attributeNames.append(0);
 }