getPixels() bug with memcpy

I am trying to copy the pixels of an image so I can send them over a socket connection. However, I get a EXC_BAD_ACCESS on the memcpy below:

  
  
ofImage img;  
img.loadImage(filename);  
img.setImageType(OF_IMAGE_COLOR);  
int sizeOfImage = img.width*img.height*3;	  
...  
unsigned char * pxs = img.getPixels();  
memcpy(message->payload_, pxs, sizeOfImage);  

Am I doing something wrong here? This seems to be logical…

Thanks for any help!

If the loadImage() is successful (maybe try checking the width and height of the image) then I can’t imagine how .getPixels() could be null.

message->payload_ on the other hand, not seeing the code for that – I would guess either message is a null pointer, or payload_ is null.