Fix leak on setaffinity error path If sched_setaffinity failed the cpus variable was not being freed. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/python-schedutils/schedutils.c b/python-schedutils/schedutils.c index dfc7cb5..fd93565 100644 --- a/python-schedutils/schedutils.c +++ b/python-schedutils/schedutils.c
@@ -182,11 +182,13 @@ CPU_SET_S(cpu, cpusetsize, cpus); } - if (sched_setaffinity(pid, sizeof(cpus), cpus) < 0) { + i = sched_setaffinity(pid, sizeof(cpus), cpus); + CPU_FREE(cpus); + + if (i < 0) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } - CPU_FREE(cpus); out: Py_INCREF(Py_None); return Py_None;