diff --git a/src/util/viruri.c b/src/util/viruri.c index d4b793f4395ea621ab291ce339c28e0d5683c1af..c8811f64c6b420c2d49bc52cd4e404e5a69780f3 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -171,7 +171,16 @@ virURIParse(const char *uri) goto error; if (VIR_STRDUP(ret->server, xmluri->server) < 0) goto error; - ret->port = xmluri->port; + /* xmluri->port value is not defined if server was + * not given. Modern versions libxml2 fill port + * differently to old versions in this case, so + * don't rely on it. eg libxml2 git commit: + * beb7281055dbf0ed4d041022a67c6c5cfd126f25 + */ + if (!ret->server || STREQ(ret->server, "")) + ret->port = 0; + else + ret->port = xmluri->port; if (VIR_STRDUP(ret->path, xmluri->path) < 0) goto error; #ifdef HAVE_XMLURI_QUERY_RAW