Heap Corruption occurring in gluTessVertex - Please help

I am trying to tesselate the interior of an irregular polygon with the following C++/Psuedo code:

I declare the following function:

vertexCallback(GLdouble *vertex)
const GLdouble *pointer;

pointer = (GLdouble *) vertex;

All the others callbacks (combine, begin, end, error) are declared as well.

I also declare the following struct:

typedef struct
double x, y, z;
} coordinate;

I created a vector as follows:

vector <coordinate> TessPath;

To add a vertex, I do the following:

coordinate loc;
loc.x = x;
loc.y = y;
loc.z = 0.0;

			gluTessVertex(tess,reinterpret_cast&lt;double*&gt;(&path[path.size() - 1]),reinterpret_cast&lt;void *&gt;(&path[path.size() - 1]));

The Tessellations are really messed up, going all over the screen.

When I run the program under valgrind, it gives the following:
==12310== Invalid read of size 4
==12310== at 0x410CD29: (within /usr/lib/libGL.so.1.2)
==12310== by 0x40F3C79: glVertex3dv (in /usr/lib/libGL.so.1.2)
==12310== by 0x408103E: (within /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x40809EE: __gl_renderMesh (in /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x40844C3: gluTessEndPolygon (in /usr/lib/libGLU.so.1.3.060402)
==12310== by 0x8067E28: Symbol::render() (in /home/fordj/Desktop/mlp/a.out)

What in the world am I doing wrong??? I have corrupted the heap somehow. When I comment out all of the Tessellation code, it runs beautifully sans filled interiors and valgrind has no complaints. The gluTessVertex, which in turn is calling glVertex3dv is the problem I believe.

It is likely that your problem is using of push_back() on vector container. Vector container allocates some memory to store its objects. When all that memory is filled by elements, the next call to push_back() will reallocate memory with new bigger size and copy old content here. The result of this is that addresses of all elements within the vector may change. Because of this, some pointers you passed to the gluTessVertex are no longer valid when gluTessEndPolygon is not called.

OF COURSE!!! Thank you!! I used TessPath.resize(10000) before adding any coordinates to see if it would work and it did. Now i just have to figure out the correct value to replace the 10000 for each contour.