summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-07-18 12:14:10 (GMT)
committerGitHub <noreply@github.com>2023-07-18 12:14:10 (GMT)
commita423ddbdeada8a2fd8657453b9e9f58ba0dd921d (patch)
tree92bf9ec6a80c41499f73a2d2e599df685ab8c4de /Modules/posixmodule.c
parentb79f3b36c318be8b27d1737a819e33145193801c (diff)
downloadcpython-a423ddbdeada8a2fd8657453b9e9f58ba0dd921d.zip
cpython-a423ddbdeada8a2fd8657453b9e9f58ba0dd921d.tar.gz
cpython-a423ddbdeada8a2fd8657453b9e9f58ba0dd921d.tar.bz2
[3.12] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855)
Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time. (cherry picked from commit 3e65baee72131b49f4ce8ca2da568a6f2001ce93)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0f82f1a..fde1e4f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -13463,7 +13463,7 @@ setup_confname_table(struct constdef *table, size_t tablesize,
}
Py_DECREF(o);
}
- return PyModule_AddObject(module, tablename, d);
+ return _PyModule_Add(module, tablename, d);
}
/* Return -1 on failure, 0 on success. */
@@ -16778,11 +16778,9 @@ posixmodule_exec(PyObject *m)
#endif
/* Initialize environ dictionary */
- PyObject *v = convertenviron();
- Py_XINCREF(v);
- if (v == NULL || PyModule_AddObject(m, "environ", v) != 0)
+ if (_PyModule_Add(m, "environ", convertenviron()) != 0) {
return -1;
- Py_DECREF(v);
+ }
if (all_ins(m))
return -1;
@@ -16897,9 +16895,7 @@ posixmodule_exec(PyObject *m)
Py_DECREF(unicode);
}
- PyModule_AddObject(m, "_have_functions", list);
-
- return 0;
+ return _PyModule_Add(m, "_have_functions", list);
}