From: Alex Jia <ajia@xxxxxxxxxx> when everything is okay, 'rv' will be 0, however, 'cleanup' lable only free allocated memory with 'rv < 0', so memory leak on successful path. The patch uses new virTypedParameterArrayClear function to free memory instead. * src/remote/remote_driver.c: fix memory leak on remoteDeserializeTypedParameters. * Detected by valgrind: ==31957== 1 bytes in 1 blocks are definitely lost in loss record 1 of 2,097 ==31957== at 0x4A05FDE: malloc (vg_replace_malloc.c:236) ==31957== by 0x39CF07F6E1: strdup (in /lib64/libc-2.12.so) ==31957== by 0xD84CDA1: remoteDeserializeTypedParameters.clone.0 (remote_driver.c:1404) ==31957== by 0xD84D11B: remoteDomainGetNumaParameters (remote_driver.c:1566) ==31957== by 0xD81EBFA: virDomainGetNumaParameters (libvirt.c:3887) ==31957== by 0xD4F8E25: libvirt_virDomainGetNumaParameters (libvirt-override.c:1127) ==31957== by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794) ==31957== by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880) ==31957== by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044) ==31957== by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545) ==31957== by 0x39E1AFB88B: run_mod (pythonrun.c:1351) ==31957== by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337) Signed-off-by: Alex Jia <ajia@xxxxxxxxxx> --- src/remote/remote_driver.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index e28840b..cfbcd0f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1417,12 +1417,7 @@ remoteDeserializeTypedParameters(remote_typed_param *ret_params_val, rv = 0; cleanup: - if (rv < 0) { - int j; - for (j = 0; j < i; j++) - if (params[j].type == VIR_TYPED_PARAM_STRING) - VIR_FREE(params[j].value.s); - } + virTypedParameterArrayClear(params, *nparams); return rv; } -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list