New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Py_DECREF->Py_XDECREF in Module/_sqlite/module.c #55319
Comments
Pretty straight forward change, but could potentially cause a NULL pointer deref in a rare situation. diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -329,7 +329,7 @@
(pysqlite_statement_setup_types() < 0) ||
(pysqlite_prepare_protocol_setup_types() < 0)
) {
- Py_DECREF(module);
+ Py_XDECREF(module);
return NULL;
} |
It may be clearer and match Python coding style better to fix it as follows: Index: Modules/_sqlite/module.c --- Modules/_sqlite/module.c (revision 88320)
+++ Modules/_sqlite/module.c (working copy)
@@ -321,14 +321,16 @@
module = PyModule_Create(&_sqlite3module);
- if (!module ||
- (pysqlite_row_setup_types() < 0) ||
- (pysqlite_cursor_setup_types() < 0) ||
- (pysqlite_connection_setup_types() < 0) ||
- (pysqlite_cache_setup_types() < 0) ||
- (pysqlite_statement_setup_types() < 0) ||
- (pysqlite_prepare_protocol_setup_types() < 0)
- ) {
+ if (module == NULL)
+ return NULL;
+
+ if (pysqlite_row_setup_types() < 0 ||
+ pysqlite_cursor_setup_types() < 0 ||
+ pysqlite_connection_setup_types() < 0 ||
+ pysqlite_cache_setup_types() < 0 ||
+ pysqlite_statement_setup_types() < 0 ||
+ pysqlite_prepare_protocol_setup_types() < 0)
+ {
Py_DECREF(module);
return NULL;
} |
Either one of these fixes (I prefer Brett's since it's shorter) should make it into 3.2. |
py3k: r88337 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: