BUG/MEDIUM: spoa/python: Fixing references to None
As per https://docs.python.org/3/c-api/none.html, None has to be treated exactly like other objects for reference counting. So, when we use it, we need to INCREF and when we are done, DECREF This patch must be backported as far as 2.0.
This commit is contained in:
parent
042f697a0f
commit
bdd034947c
|
@ -634,6 +634,7 @@ static int ps_python_exec_message(struct worker *w, void *ref, int nargs, struct
|
||||||
|
|
||||||
switch (args[i].value.type) {
|
switch (args[i].value.type) {
|
||||||
case SPOE_DATA_T_NULL:
|
case SPOE_DATA_T_NULL:
|
||||||
|
Py_INCREF(Py_None);
|
||||||
value = Py_None;
|
value = Py_None;
|
||||||
break;
|
break;
|
||||||
case SPOE_DATA_T_BOOL:
|
case SPOE_DATA_T_BOOL:
|
||||||
|
@ -722,6 +723,7 @@ static int ps_python_exec_message(struct worker *w, void *ref, int nargs, struct
|
||||||
value = PY_BYTES_FROM_STRING_AND_SIZE(args[i].value.u.buffer.str, args[i].value.u.buffer.len);
|
value = PY_BYTES_FROM_STRING_AND_SIZE(args[i].value.u.buffer.str, args[i].value.u.buffer.len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Py_INCREF(Py_None);
|
||||||
value = Py_None;
|
value = Py_None;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -786,9 +788,7 @@ static int ps_python_exec_message(struct worker *w, void *ref, int nargs, struct
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (result != Py_None) {
|
Py_DECREF(result);
|
||||||
Py_DECREF(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue