upnp: refactor using C++ try/catch
The try/catch for exception safety was already needed there, and this simplify the code a lot, so this moves the allocation into unique_ptr to benefit from RAII destructors.
In addition, this commit change the call to free(p_sys) into the correct C++ delete, avoiding a mismatch new/free.
Introduced in 0d89fe3f.