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

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@mail.ustc.edu.cn> --- 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

On 01/06/2017 09:28 AM, Wu Zongyong wrote:
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@mail.ustc.edu.cn> --- libvirt-override.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
ACK (and pushed)... I also pushed a post release version bump adjustment too. Looks like these were not done as part of commit id '71fd954092' Thanks! John In the future - if you have "libvirt-python" in the title it makes it easier to spot as a python issue rather than libvirt issue. Modify your .git/config file in your libvirt-python.git with an entry such as: [format] subjectprefix = libvirt-python PATCH
participants (2)
-
John Ferlan
-
Wu Zongyong