Thanks guys. I fixed it when I made my terrain size 257x257. I accessed each vertex like as if it were 2D grid (which it is) so the extra vertices are not read.
Each chunk is 33x33 vertices now, so the math works out.
What I was doing was a little something like this:
DWORD dwTotalVertices, dwVertices;
D3DVERTEX* pVertices;
...
dwTotalVertices = pMesh->GetNumVertices();
dwVertices = (DWORD)ceil(sqrt((double)dwTotalVertices));
...
pMesh->LockVertexBuffer(0, (LPVOID*)&pVertices);
for (unsigned y = 0; y < 32; ++y) {
for (unsigned x = 0; x < 32; ++x) {
float h = pVertices[x+y*dwVertices].y;
}
}
pMesh->UnlockVertexBuffer();