Potentially accessing already freed pointer

Do not access r if chatr_free has been called on it