glmReadPPM function error

Hi, I am trying to load image from a .ppm file. I use the code from Nate’s tutorial, namely the glmReadPPM function.

I have the foolowing line in my testing code:

m_image = glmReadPPM((char *)m_ppmName.c_str(), &iwidth, &iheight);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iwidth, iheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_image);

However, the program crashes at glTexImage2D fucntion. What could be wrong? m_image is not NULL, but I am not sure if it has the correct stuff.