If you use a pointer, make sure that it is filled:

while(pointer == NULL){wait(1);}

or even shorter:

while(!pointer){wait(1);}

This will pause the function until the pointer is valid.


no science involved