esp_netif: Fixed possible use of hostname pointer after its freed
esp_netif: Fixed possible use of hostname pointer after its freed

When setting hostname using esp_netif_set_hostname_api() failed for some reason, the netif pointer might be freed while lwip pointer stil point to that location and could be used. Fixed by moving the freeing and string duplication to the block where lwip hostname is set.

Closes https://github.com/espressif/esp-idf/issues/6048

espressif/esp-idf,espressif/esp-idf,espressif/esp-idf,espressif/esp-idf