EXCEPTION_ACCESS_VIOLATION with glReadPixels

I’m getting an EXCEPTION_ACCESS_VIOLATION error when I use glReadPixels. I’ve looked on the net for solutions without any luck. One person posted that using Java 1.5 but that’s what I’m running and I still get the error. Any ideas?

That’s usually a buffer overflow or index out of bounds
kind of error. Is your buffer the same size as what you
requested from glReadPixels()?

That seemed to fix it. I’m not sure why though. I was initialize my buffer with width * height * 3 and using GL_RGB and GL_UNSIGNEDBYTE in the glReadPixel command. I changed the 3 to a 4 and now it works fine. Any idea why it wouldn’t work with 3? Shouldn’t the R, G and B use up on byte each?