mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-17 11:10:42 +00:00
BUG/MINOR: spoa/python: Cleanup ipaddress objects if initialization fails
This change is to ensure objects from the ipaddress module are cleaned up when spoa module initialization fails. In general the interpreter would just crash, but in a code where import is conditional (try/except), then we would keep those objects around This patch must be backported as far as 2.0.
This commit is contained in:
parent
132d8f61e9
commit
d1c0cf80bc
@ -410,18 +410,24 @@ static int ps_python_start_worker(struct worker *w)
|
||||
|
||||
ipv4_address = PyObject_GetAttrString(module_ipaddress, "IPv4Address");
|
||||
if (ipv4_address == NULL) {
|
||||
Py_DECREF(module_ipaddress);
|
||||
PyErr_Print();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ipv6_address = PyObject_GetAttrString(module_ipaddress, "IPv6Address");
|
||||
if (ipv6_address == NULL) {
|
||||
Py_DECREF(ipv4_address);
|
||||
Py_DECREF(module_ipaddress);
|
||||
PyErr_Print();
|
||||
return 0;
|
||||
}
|
||||
|
||||
PY_INIT_MODULE(m, "spoa", spoa_methods, &spoa_module_definition);
|
||||
if (m == NULL) {
|
||||
Py_DECREF(ipv4_address);
|
||||
Py_DECREF(ipv6_address);
|
||||
Py_DECREF(module_ipaddress);
|
||||
PyErr_Print();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user