Module: kamailio
Branch: master
Commit: dc0586bbf6743080f500800808593d6cc1007945
URL:
https://github.com/kamailio/kamailio/commit/dc0586bbf6743080f500800808593d6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-03-22T04:46:54+01:00
app_python: avoid releasing uninitialized gstate
---
Modified: src/modules/app_python/python_exec.c
---
Diff:
https://github.com/kamailio/kamailio/commit/dc0586bbf6743080f500800808593d6…
Patch:
https://github.com/kamailio/kamailio/commit/dc0586bbf6743080f500800808593d6…
---
diff --git a/src/modules/app_python/python_exec.c b/src/modules/app_python/python_exec.c
index f5f4d02532..9d3abf492a 100644
--- a/src/modules/app_python/python_exec.c
+++ b/src/modules/app_python/python_exec.c
@@ -69,6 +69,7 @@ int apy_exec(sip_msg_t *_msg, char *fname, char *fparam, int emode)
int mpid;
int locked = 0;
PyGILState_STATE gstate;
+ int gstate_init = 0;
bmsg = _sr_apy_env.msg;
_sr_apy_env.msg = _msg;
@@ -87,6 +88,7 @@ int apy_exec(sip_msg_t *_msg, char *fname, char *fparam, int emode)
}
}
PY_GIL_ENSURE;
+ gstate_init = 1;
}
pFunc = PyObject_GetAttrString(_sr_apy_handler_obj, fname);
@@ -164,7 +166,7 @@ int apy_exec(sip_msg_t *_msg, char *fname, char *fparam, int emode)
Py_DECREF(pResult);
_sr_apy_env.msg = bmsg;
err:
- PY_GIL_RELEASE;
+ if(gstate_init) { PY_GIL_RELEASE; }
LOCK_RELEASE;
return rval;
}