Read pixel data error?

Hi,
I want to read pixel data such as z-buffer and color on the screen. When i read data per row, then the result is correct. But when I do with the whole screen, there is something wrong(It’s color data).
My code is as following,
int size=m_viewportWidthm_viewportHeight;//size=926722
m_fZBuffer=new float[p];
m_ubtColor=new BYTE[p];

// glReadPixels(0,0,m_viewportWidth,m_viewportHeight,GL_DEPTH_COMPONENT,GL_FLOAT,m_fZBuffer);//error
// glReadPixels(0,0,m_viewportWidth,m_viewportHeight,GL_GREEN,GL_UNSIGNED_BYTE,m_ubtColor); //error

float zbf[926];
BYTE  clr[926];
for(int i=0; i<m_winHeight; i++)
{
	glReadPixels(0,i,m_viewportWidth,1,GL_DEPTH_COMPONENT,GL_FLOAT,zbf);	//right
	glReadPixels(0,i,m_viewportWidth,1,GL_GREEN,GL_UNSIGNED_BYTE,clr);	//right

	for(int j=0; j<m_viewportWidth; j++)
	{
		int p = i*m_viewportWidth+j;
		m_fZBuffer[p]=zbf[j];
		m_ubtColor[p]=clr[j];
	}
}

Does anyone know what’s wrong with my code?
Thanks.

Huh oh. Viewport of 926 x 722 + using glReadPixels ? The first thing i’d look into is the unpack alignment that you can specify with glPixelStorei.

Y.