core: address several advertised address related issues

	* properly duplicate buffers into shared memory when required
	* keep the advertised address of the first branch as a default for
	  future branches
	* also allow set_advertised_port() to receive any kind of parameter
	  (int, string, int pvar, str pvar...)

Credits for reporting and helping with troubleshooting to GitHub user contact2malay
(cherry picked from commit ad92fa6ff6f61073270b311475fb9840361b4f2e)