File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ void load_tkinter_funcs(void)
161
161
void load_tkinter_funcs (void )
162
162
{
163
163
// Load tkinter global funcs from tkinter compiled module.
164
- void *main_program, *tkinter_lib;
164
+ void *main_program = NULL , *tkinter_lib = NULL ;
165
165
PyObject *module = NULL , *py_path = NULL , *py_path_b = NULL ;
166
166
char *path;
167
167
@@ -190,11 +190,18 @@ void load_tkinter_funcs(void)
190
190
PyErr_SetString (PyExc_RuntimeError, dlerror ());
191
191
goto exit ;
192
192
}
193
- load_tk (tkinter_lib);
194
- // dlclose is safe because tkinter has been imported.
195
- dlclose (tkinter_lib);
196
- goto exit ;
193
+ if ( load_tk (tkinter_lib)) {
194
+ goto exit ;
195
+ }
196
+
197
197
exit :
198
+ // We don't need to keep a reference open as the main program & tkinter
199
+ // have been imported. Use a non-short-circuiting "or" to try closing both
200
+ // handles before handling errors.
201
+ if ((main_program && dlclose (main_program))
202
+ | (tkinter_lib && dlclose (tkinter_lib))) {
203
+ PyErr_SetString (PyExc_RuntimeError, dlerror ());
204
+ }
198
205
Py_XDECREF (module);
199
206
Py_XDECREF (py_path);
200
207
Py_XDECREF (py_path_b);
You can’t perform that action at this time.
0 commit comments