[PATCH] Fix the incorrect memory freeing which will result in crash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The number of elements in new_params is equal to the length of info,
instead of nparams, so it's wrong to free new_params using nparams.

Signed-off-by: Wu Zongyong <wuzongyo@xxxxxxxxxxxxxxxx>
---
 libvirt-override.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index db14244..dac4250 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -632,7 +632,7 @@ libvirt_virDomainSetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
     int nparams = 0;
     Py_ssize_t size = 0;
     unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
+    virTypedParameterPtr params = NULL, new_params = NULL;
 
     if (!PyArg_ParseTuple(args,
                           (char *)"OOI:virDomainSetScedulerParametersFlags",
@@ -694,7 +694,7 @@ libvirt_virDomainSetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
 
  cleanup:
     virTypedParamsFree(params, nparams);
-    virTypedParamsFree(new_params, nparams);
+    virTypedParamsFree(new_params, size);
     return ret;
 }
 
@@ -7682,7 +7682,7 @@ libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
     int nparams = 0;
     Py_ssize_t size = 0;
     unsigned int flags;
-    virTypedParameterPtr params, new_params = NULL;
+    virTypedParameterPtr params = NULL, new_params = NULL;
 
     if (!PyArg_ParseTuple(args,
                           (char *)"OOI:virNodeSetMemoryParameters",
@@ -7741,7 +7741,7 @@ libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
 
  cleanup:
     virTypedParamsFree(params, nparams);
-    virTypedParamsFree(new_params, nparams);
+    virTypedParamsFree(new_params, size);
     return ret;
 }
 
-- 
2.10.0.windows.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux