KR> + count = get_domain_list(conn, &list);
KR> + if (count <= 0)
KR> + goto out;
You create the list before the for() loop,
KR> +
KR> + for (i = 0; i < count; i++) {
KR> + name = virDomainGetName(list[i]);
KR> + if (name == NULL) {
KR> + cu_statusf(_BROKER, &s,
KR> + CMPI_RC_ERR_FAILED,
KR> + "Unable to get domain names");
KR> + goto end;
KR> + }
KR> +
KR> + s = get_ele_cap(_BROKER, ref, name, &inst);
KR> + if (s.rc != CMPI_RC_OK)
KR> + goto end;
KR> +
KR> + if (names_only)
KR> + cu_return_instance_name(results, inst);
KR> + else
KR> + CMReturnInstance(results, inst);
KR> +
KR> + end:
KR> + virDomainFree(list[i]);
KR> +
KR> + if (s.rc != CMPI_RC_OK)
KR> + goto out;
But then clean it up every time through the loop, which should be
causing a crash on the 1..n iterations. If you're not seeing a
crash, I imagine you're getting lucky. virDomainFree() protects
against a double-free with some magic, I think, but using list after
the first time through here is broken.
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com