Avoid segfault when freeing rules whose target could not be found