From 65edf2258f359078e98291fb348bccc88653539a Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Fri, 23 Nov 2018 16:02:46 +0000 Subject: #1360: Leak of SWIG var link object --- Lib/python/pyinit.swg | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Lib/python') diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 621d6f9ed..dd58bad0b 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -227,7 +227,11 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + if (!_SWIG_globals) { + _SWIG_globals = SWIG_newvarlink(); + } else { + Py_INCREF(_SWIG_globals); + } return _SWIG_globals; } @@ -326,7 +330,7 @@ SWIGEXPORT void #endif SWIG_init(void) { - PyObject *m, *d, *md; + PyObject *m, *d, *md, *globals; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, -- cgit v1.2.1 From 493d96a732cda7c51fb2a6192a3441053cef8c88 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Sat, 24 Nov 2018 20:07:44 +0000 Subject: Fix unused variable warning. --- Lib/python/pyinit.swg | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/python') diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index dd58bad0b..6516b5159 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -331,6 +331,9 @@ SWIGEXPORT #endif SWIG_init(void) { PyObject *m, *d, *md, *globals; + + (void)globals; + #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, -- cgit v1.2.1 From 3c090307a48b0c6a1f034357b751bc9469cc111f Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Sun, 25 Nov 2018 04:23:18 +0000 Subject: Fix ISOC build errors. --- Lib/python/pyinit.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/python') diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 6516b5159..c155185cd 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -332,8 +332,6 @@ SWIGEXPORT SWIG_init(void) { PyObject *m, *d, *md, *globals; - (void)globals; - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, @@ -386,6 +384,8 @@ SWIG_init(void) { assert(metatype); #endif + (void)globals; + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ SWIG_This(); SWIG_Python_TypeCache(); -- cgit v1.2.1 From 0fecd1538faa45b5818776b676be41aca7780c25 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 27 Nov 2018 23:30:51 +0000 Subject: Cleanup accessing/decref of globals, to avoid code bloat in init function. --- Lib/python/pyinit.swg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Lib/python') diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index c155185cd..d8f3bf444 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -227,11 +227,7 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) { - _SWIG_globals = SWIG_newvarlink(); - } else { - Py_INCREF(_SWIG_globals); - } + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } -- cgit v1.2.1