core: fix compiler warning and a rare mem leak

	* setting the global advertised port multiple times leaked pkg mem
(cherry picked from commit a99688e9bb801fae28a009174b7145688a8b204a)