Pointers are great
The greatest fixes to all your pointer issues:
if (refVal != null) { //Do the thing } else { //Optional in case if your reference value is uninitialized, can be useful for certain things too }
The greatest fix to all your pointer issues are to use references.
Or using a different programming language that abstracts all that shit away because the people who made it are almost certainly better at memory management than I am!