- return talloc_asprintf(url, "%s://%s%s", scheme->str,
- scheme->has_host ? url->host : "", url->path);
+ str = talloc_asprintf(url, "%s://%s%s%s", scheme->str,
+ scheme->has_host ? url->host : "",
+ port ?: "", url->path);
+
+ talloc_free(port);
+ return str;