Valgrind Invalid write of size 8 with QGLBuffer map
===

I am using Qt + OpenGL + GLSL to draw a lot points in a 3D scene and I need to change the color of some points.

To initialize the color VBO I did that:

    cores = new QVector3D[num_vertices];

    for(int i = 0; i < num_vertices; i++)
        cores[i] = QVector3D(1.0, 1.0, 1.0);
    m_vboCores = new QGLBuffer(QGLBuffer::VertexBuffer);
    m_vboCores->create();
    m_vboCores->bind();
    m_vboCores->setUsagePattern(QGLBuffer::DynamicDraw);
    m_vboCores->allocate(cores, num_vertices*sizeof(QVector3D));

In the application I change the value of some elements in *cores* vector, and in the *paintGL* function I am doing that:

    m_vboCores->bind();
    QVector3D *vCores = (QVector3D*) m_vboCores->map(QGLBuffer::WriteOnly);
    for(i = 0; i < num_vertices; i++)
        vCores[i] = cores[i];
    m_vboCores->unmap();
    m_shaderProgram->enableAttributeArray("Cor_Vertice");
    m_shaderProgram->setAttributeBuffer("Cor_Vertice", GL_FLOAT, 0, 3, 0);

And Valgrind says that are invalid write in this line:

    vCores[i] = cores[i];

But I have used *printf* to check the value of *i*, and the index *i* is not out of bound...
What can I doing wrong?

