File fix-for-cve-2019-18874.diff of Package python-psutil
Index: psutil-release-5.0.1/psutil/_psutil_bsd.c
===================================================================
--- psutil-release-5.0.1.orig/psutil/_psutil_bsd.c
+++ psutil-release-5.0.1/psutil/_psutil_bsd.c
@@ -150,7 +150,7 @@ psutil_pids(PyObject *self, PyObject *ar
goto error;
if (PyList_Append(py_retlist, py_pid))
goto error;
- Py_DECREF(py_pid);
+ Py_CLEAR(py_pid);
proclist++;
}
free(orig_address);
@@ -734,7 +734,7 @@ psutil_net_io_counters(PyObject *self, P
goto error;
if (PyDict_SetItemString(py_retdict, ifc_name, py_ifc_info))
goto error;
- Py_DECREF(py_ifc_info);
+ Py_CLEAR(py_ifc_info);
}
else {
continue;
Index: psutil-release-5.0.1/psutil/_psutil_osx.c
===================================================================
--- psutil-release-5.0.1.orig/psutil/_psutil_osx.c
+++ psutil-release-5.0.1/psutil/_psutil_osx.c
@@ -786,7 +786,7 @@ psutil_per_cpu_times(PyObject *self, PyO
goto error;
if (PyList_Append(py_retlist, py_cputime))
goto error;
- Py_DECREF(py_cputime);
+ Py_CLEAR(py_cputime);
}
ret = vm_deallocate(mach_task_self(), (vm_address_t)info_array,
@@ -1010,7 +1010,6 @@ psutil_proc_threads(PyObject *self, PyOb
}
for (j = 0; j < thread_count; j++) {
- py_tuple = NULL;
thread_info_count = THREAD_INFO_MAX;
kr = thread_info(thread_list[j], THREAD_BASIC_INFO,
(thread_info_t)thinfo_basic, &thread_info_count);
@@ -1031,7 +1030,7 @@ psutil_proc_threads(PyObject *self, PyOb
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
ret = vm_deallocate(task, (vm_address_t)thread_list,
@@ -1326,7 +1325,7 @@ psutil_proc_connections(PyObject *self,
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
else if (family == AF_UNIX) {
// construct the python list
@@ -1460,7 +1459,7 @@ psutil_net_io_counters(PyObject *self, P
goto error;
if (PyDict_SetItemString(py_retdict, ifc_name, py_ifc_info))
goto error;
- Py_DECREF(py_ifc_info);
+ Py_CLEAR(py_ifc_info);
}
else {
continue;
@@ -1633,7 +1632,7 @@ psutil_disk_io_counters(PyObject *self,
goto error;
if (PyDict_SetItemString(py_retdict, disk_name, py_disk_info))
goto error;
- Py_DECREF(py_disk_info);
+ Py_CLEAR(py_disk_info);
CFRelease(parent_dict);
IOObjectRelease(parent);
Index: psutil-release-5.0.1/psutil/_psutil_sunos.c
===================================================================
--- psutil-release-5.0.1.orig/psutil/_psutil_sunos.c
+++ psutil-release-5.0.1/psutil/_psutil_sunos.c
@@ -487,8 +487,7 @@ psutil_per_cpu_times(PyObject *self, PyO
goto error;
if (PyList_Append(py_retlist, py_cputime))
goto error;
- Py_DECREF(py_cputime);
- py_cputime = NULL;
+ Py_CLEAR(py_cputime);
}
}
@@ -544,7 +543,7 @@ psutil_disk_io_counters(PyObject *self,
if (PyDict_SetItemString(py_retdict, ksp->ks_name,
py_disk_info))
goto error;
- Py_DECREF(py_disk_info);
+ Py_CLEAR(py_disk_info);
}
}
ksp = ksp->ks_next;
@@ -791,7 +790,7 @@ psutil_net_io_counters(PyObject *self, P
goto error;
if (PyDict_SetItemString(py_retdict, ksp->ks_name, py_ifc_info))
goto error;
- Py_DECREF(py_ifc_info);
+ Py_CLEAR(py_ifc_info);
goto next;
next:
@@ -979,7 +978,7 @@ psutil_net_connections(PyObject *self, P
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
}
#if defined(AF_INET6)
@@ -1052,7 +1051,7 @@ psutil_net_connections(PyObject *self, P
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
}
#if defined(AF_INET6)
@@ -1081,7 +1080,7 @@ psutil_net_connections(PyObject *self, P
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
}
#endif
@@ -1254,7 +1253,7 @@ psutil_net_if_stats(PyObject* self, PyOb
goto error;
if (PyDict_SetItemString(py_retdict, ksp->ks_name, py_ifc_info))
goto error;
- Py_DECREF(py_ifc_info);
+ Py_CLEAR(py_ifc_info);
}
}
Index: psutil-release-5.0.1/psutil/_psutil_windows.c
===================================================================
--- psutil-release-5.0.1.orig/psutil/_psutil_windows.c
+++ psutil-release-5.0.1/psutil/_psutil_windows.c
@@ -291,7 +291,7 @@ psutil_pids(PyObject *self, PyObject *ar
goto error;
if (PyList_Append(py_retlist, py_pid))
goto error;
- Py_DECREF(py_pid);
+ Py_CLEAR(py_pid);
}
// free C array allocated for PIDs
@@ -1006,7 +1006,7 @@ psutil_per_cpu_times(PyObject *self, PyO
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
free(sppi);
@@ -1228,7 +1228,7 @@ psutil_proc_threads(PyObject *self, PyOb
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
CloseHandle(hThread);
}
@@ -2312,8 +2312,8 @@ psutil_net_io_counters(PyObject *self, P
goto error;
if (PyDict_SetItem(py_retdict, py_nic_name, py_nic_info))
goto error;
- Py_XDECREF(py_nic_name);
- Py_XDECREF(py_nic_info);
+ Py_CLEAR(py_nic_name);
+ Py_CLEAR(py_nic_info);
free(pIfRow);
pCurrAddresses = pCurrAddresses->Next;
@@ -2662,7 +2662,7 @@ psutil_users(PyObject *self, PyObject *a
goto error;
Py_XDECREF(py_buffer_user_encoded);
Py_XDECREF(py_address);
- Py_XDECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
WTSFreeMemory(sessions);
@@ -2935,8 +2935,8 @@ psutil_ppid_map(PyObject *self, PyObject
goto error;
if (PyDict_SetItem(py_retdict, py_pid, py_ppid))
goto error;
- Py_DECREF(py_pid);
- Py_DECREF(py_ppid);
+ Py_CLEAR(py_pid);
+ Py_CLEAR(py_ppid);
} while (Process32Next(handle, &pe));
}
@@ -3044,8 +3044,8 @@ psutil_net_if_addrs(PyObject *self, PyOb
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
- Py_DECREF(py_mac_address);
+ Py_CLEAR(py_tuple);
+ Py_CLEAR(py_mac_address);
}
// find out the IP address associated with the NIC
@@ -3118,14 +3118,14 @@ psutil_net_if_addrs(PyObject *self, PyOb
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
- Py_DECREF(py_address);
- Py_DECREF(py_netmask);
+ Py_CLEAR(py_tuple);
+ Py_CLEAR(py_address);
+ Py_CLEAR(py_netmask);
pUnicast = pUnicast->Next;
}
}
- Py_DECREF(py_nic_name);
+ Py_CLEAR(py_nic_name);
pCurrAddresses = pCurrAddresses->Next;
}
@@ -3245,8 +3245,8 @@ psutil_net_if_stats(PyObject *self, PyOb
goto error;
if (PyDict_SetItem(py_retdict, py_nic_name, py_ifc_info))
goto error;
- Py_DECREF(py_nic_name);
- Py_DECREF(py_ifc_info);
+ Py_CLEAR(py_nic_name);
+ Py_CLEAR(py_ifc_info);
}
free(pIfTable);
Index: psutil-release-5.0.1/psutil/_psutil_linux.c
===================================================================
--- psutil-release-5.0.1.orig/psutil/_psutil_linux.c
+++ psutil-release-5.0.1/psutil/_psutil_linux.c
@@ -220,7 +220,7 @@ psutil_disk_partitions(PyObject *self, P
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
endmntent(file);
return py_retlist;
@@ -459,7 +459,7 @@ psutil_users(PyObject *self, PyObject *a
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_tuple);
}
endutent();
return py_retlist;