It is good practice to either do a runtime check like this or to add an assert for debugging purposes like this:For now I do not know how to check if the pointer is still valid
This doesn't help if the pointer is non-null but also not valid (in other words, you pass a pointer variable that has not been initialized).
The assert will result in your program stopping at that point when you run it in the debugger. From that point, you can use the debugger to trace back through the call stack to find where things went wrong.
If you don't know how to use a debugger, you have to learn. The dump you get from a SEGFAULT when running a realease mode version of your program is pretty much useless for debugging purposes.
Bookmarks