segfault after glGetTexImage

Im trying to save my rendered image as a .ppm file but if I use glGetTexImage() and after that glUseProgram() I always get segmentation fault.
Do anyone know why I get this error.
This is the way I get my texture data : glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_BYTE, pixelBuffer);
(If I dont use glGetTexImage I dont get any error).

Is pixelBuffer sized large enough to recieve the data?

And if you are expecting tightly-package RGB8 data to be returned, have you specified:

glPixelStorei(GL_PACK_ALIGNMENT, 1)

For details, see this section in the OpenGL wiki: