Validate pointer before using it