Skip to content

Commit f908d32

Browse files
[python, Bridge] Return incorrectly removed Py_DECREF's on reused Python variables
1 parent b801abe commit f908d32

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lang_python/oif_impl/bridge_python.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,14 @@ load_impl(const char *impl_details, size_t version_major, size_t version_minor)
237237
return NULL;
238238
}
239239
pModule = PyImport_Import(pFileName);
240+
Py_DECREF(pFileName);
240241

241242
if (pModule == NULL) {
242243
fprintf(stderr, "[%s] Could not import `sysconfig` module\n", prefix_);
243244
return NULL;
244245
}
245246
pFunc = PyObject_GetAttrString(pModule, "get_config_var");
247+
Py_DECREF(pModule);
246248
if (pFunc == NULL || !PyCallable_Check(pFunc)) {
247249
fprintf(stderr, "[%s] Could not find function `sysconfig.get_config_var`\n", prefix_);
248250
return NULL;
@@ -396,7 +398,7 @@ load_impl(const char *impl_details, size_t version_major, size_t version_minor)
396398
Py_XDECREF(pFileName);
397399
Py_XDECREF(pModule);
398400
Py_XDECREF(pClass);
399-
/* Py_XDECREF(pInstance); */
401+
/* Py_XDECREF(pInstance); We keep it inside an impl_info object. */
400402
Py_XDECREF(pFunc);
401403
Py_XDECREF(pInitArgs);
402404
Py_XDECREF(pArgs);

0 commit comments

Comments
 (0)