Check if error != NULL before assigning value.