提交 f733eac0 编写于 作者: J Ján Tomko

virsh: free the list from ListAll APIs even for 0 items

virsh secret-list leak when no secrets are defined:

==27== 8 bytes in 1 blocks are definitely lost in loss record 6 of 726
==27==    by 0x4E941DD: virAllocN (viralloc.c:183)
==27==    by 0x5037F1A: remoteConnectListAllSecrets (remote_driver.c:3076)
==27==    by 0x5004EC6: virConnectListAllSecrets (libvirt.c:16298)
==27==    by 0x15F813: vshSecretListCollect (virsh-secret.c:397)
==27==    by 0x15F0E1: cmdSecretList (virsh-secret.c:532)

And so do some other *-list commands.

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
上级 66d124b4
......@@ -174,7 +174,7 @@ vshInterfaceListFree(vshInterfaceListPtr list)
{
size_t i;
if (list && list->nifaces) {
if (list && list->ifaces) {
for (i = 0; i < list->nifaces; i++) {
if (list->ifaces[i])
virInterfaceFree(list->ifaces[i]);
......
......@@ -423,7 +423,7 @@ vshNetworkListFree(vshNetworkListPtr list)
{
size_t i;
if (list && list->nnets) {
if (list && list->nets) {
for (i = 0; i < list->nnets; i++) {
if (list->nets[i])
virNetworkFree(list->nets[i]);
......
......@@ -207,7 +207,7 @@ vshNodeDeviceListFree(vshNodeDeviceListPtr list)
{
size_t i;
if (list && list->ndevices) {
if (list && list->devices) {
for (i = 0; i < list->ndevices; i++) {
if (list->devices[i])
virNodeDeviceFree(list->devices[i]);
......
......@@ -242,7 +242,7 @@ vshNWFilterListFree(vshNWFilterListPtr list)
{
size_t i;
if (list && list->nfilters) {
if (list && list->filters) {
for (i = 0; i < list->nfilters; i++) {
if (list->filters[i])
virNWFilterFree(list->filters[i]);
......
......@@ -370,7 +370,7 @@ vshSecretListFree(vshSecretListPtr list)
{
size_t i;
if (list && list->nsecrets) {
if (list && list->secrets) {
for (i = 0; i < list->nsecrets; i++) {
if (list->secrets[i])
virSecretFree(list->secrets[i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册