Avoiding arithmetic on NULL pointer