From: Ján Tomko Date: Tue, 28 Mar 2017 13:11:52 +0000 (+0200) Subject: conf: do not steal pointers from the pool source X-Git-Tag: v2.2.1~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47fa3d3992b18c27d5aafb9f6503cd79cb827aad;p=thirdparty%2Flibvirt.git conf: do not steal pointers from the pool source Since commit fcbbb28 we steal the pointer to the storage pool source name if there was no pool name specified. Properly duplicate the string to avoid freeing it twice. https://bugzilla.redhat.com/show_bug.cgi?id=1436400 (cherry picked from commit e9f9690958b7fc86c4002c16cd2bdccba0dd07d1) --- diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 05a1a49cee..36e579e40f 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -845,8 +845,9 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL && - options->flags & VIR_STORAGE_POOL_SOURCE_NAME) - ret->name = ret->source.name; + options->flags & VIR_STORAGE_POOL_SOURCE_NAME && + VIR_STRDUP(ret->name, ret->source.name) < 0) + goto error; if (ret->name == NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing pool source name element")); diff --git a/tests/storagepoolxml2xmlout/pool-logical-noname.xml b/tests/storagepoolxml2xmlout/pool-logical-noname.xml new file mode 100644 index 0000000000..a5e0ead6d2 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-logical-noname.xml @@ -0,0 +1,19 @@ + + zily + 1c13165a-d0f4-3aee-b447-30fb38789091 + 0 + 0 + 0 + + zily + + + + /dev/zily + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 2e1e811aec..37765bc4bd 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -79,6 +79,7 @@ mymain(void) DO_TEST("pool-logical"); DO_TEST("pool-logical-nopath"); DO_TEST("pool-logical-create"); + DO_TEST("pool-logical-noname"); DO_TEST("pool-disk"); DO_TEST("pool-disk-device-nopartsep"); DO_TEST("pool-iscsi");