diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-12 00:42:58 +0000 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-12 00:42:58 +0000 |
commit | 94377b822f366650f6c69a90e09e18b9148ec637 (patch) | |
tree | 7da65bcfbe1b9fb60c7b644f4510804bad8abedf /bindings/python | |
parent | 93bea174743af203189e6b4b7e0ba8f206d28d0b (diff) | |
download | lasso-94377b822f366650f6c69a90e09e18b9148ec637.tar.gz lasso-94377b822f366650f6c69a90e09e18b9148ec637.tar.xz lasso-94377b822f366650f6c69a90e09e18b9148ec637.zip |
Binding python: fix bad refcounting in get_logger and lasso_python_log
Diffstat (limited to 'bindings/python')
-rw-r--r-- | bindings/python/wrapper_top.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/bindings/python/wrapper_top.c b/bindings/python/wrapper_top.c index 7a2d308c..09ceff84 100644 --- a/bindings/python/wrapper_top.c +++ b/bindings/python/wrapper_top.c @@ -604,15 +604,20 @@ static PyObject *get_logger_object() { static PyObject *_logger_object = NULL; PyObject *logging_module = PyImport_ImportModule("lasso"); - _logger_object = PyObject_GetAttrString(logging_module, "logger"); - if (_logger_object) - goto exit; - Py_DECREF(logging_module); + + if (logging_module) { + _logger_object = PyObject_GetAttrString(logging_module, "logger"); + Py_DECREF(logging_module); + if (_logger_object) + goto exit; + } logging_module = PyImport_ImportModule("logging"); - _logger_object = PyObject_CallMethod(logging_module, "getLogger", - "s#", "lasso", sizeof("lasso")-1); + if (logging_module) { + _logger_object = PyObject_CallMethod(logging_module, "getLogger", + "s#", "lasso", sizeof("lasso")-1); + Py_DECREF(logging_module); + } exit: - Py_DECREF(logging_module); if (_logger_object == Py_None) { Py_DECREF(_logger_object); _logger_object = NULL; @@ -653,6 +658,7 @@ lasso_python_log(G_GNUC_UNUSED const char *domain, GLogLevelFlags log_level, con return; } result = PyObject_CallMethod(logger_object, method, "s#s", "%s", 2, message); + Py_DECREF(logger_object); if (result) { Py_DECREF(result); } else { |