Simple pointer return goes wrong

Hello,

I'm trying to do a simple pointer return but the program keeps crashing. It's a simple solution but I looked at code today so I'm a little blah.

The transfer fuction is

1
2
3
4
unsigned char *  Terrain::GetData()
{
    return (unsigned char *)proceduralImageCreated -> GetData();
}

GetData() is based on this

http://urho3d.github.io/documentation/1.32/class_urho3_d_1_1_image.html#a4493750ec073340f56269e34b2e9aca9

1
2
unsigned char * 	GetData () const
 	Return pixel data. 


I'm using the following lines

1
2
3
   Image * producedHeightMapImage = new Image(context_);
    producedHeightMapImage -> SetSize(1024,1024, 1, 4);
    producedHeightMapImage -> SetData(terrain -> GetData());



The Image that creates proceduralImageCreated is correct.

So I'm a little lost.

Vivienne
What's the signal caught? Segfault?
Also, is that the exact line causing the crash?
Last edited on
I'm trying to do a simple pointer return but the program keeps crashing.
There are a number of things that could cause that crash. The first one is always, is the pointer null or uninitialised?

If you want to track the actual crash, it's normal to run the program in a debugger and let it crash. The debugger will show the function it crashed in, and the call stack. If the program was built for debug, you'll also be able to see local variables for each function in your program that's in the call stack.

Once you can see where it's crashing, you can work backwards to work out why.
Topic archived. No new replies allowed.