get_comp() will always return NULL or a new string, and so a double free won't happen, and a free() of a NULL pointer is OK. But, it is a bit pointless to always unconditionally free(comp) and then check whether it is not NULL immediately afterwards.
BTW you have forgotten to add brackets, as there are now more than one statement in the if. I'll fix it after applying it.
get_comp() will always return NULL or a new string, and so a double free won't happen, and a free() of a NULL pointer is OK. But, it is a bit pointless to always unconditionally free(comp) and then check whether it is not NULL immediately afterwards.
BTW you have forgotten to add brackets, as there are now more than one statement in the if. I'll fix it after applying it.