I'm using OpenCV and SDL in tandem, I've declared a Mat in a function and once I'm done with it I give it's data to create an SDL_Surface, I'm assuming that once we leave the function scope the mat is recycled? I'm getting an access violation as soon as I use the sdl_surface and the data it contains is garbage.
I can also say that the function SDL_CreateRGBSurfaceFrom doesn't copy the data is uses what's stored at the pointer.
Here's the function, I haven't written C++ in a while so perhaps I'm making a big mistake: http://pastie.org/4333990