Skip to content
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

Closed
brettcannon opened this issue Feb 4, 2011 · 4 comments
Closed

Py_DECREF->Py_XDECREF in Module/_sqlite/module.c #55319

brettcannon opened this issue Feb 4, 2011 · 4 comments
Labels
extension-modules C modules in the Modules dir release-blocker

Comments

@brettcannon
Copy link
Member

BPO 11110
Nosy @brettcannon, @birkenfeld, @abalkin
Files
  • fix_sqlite.diff: Change a Py_DECREF to Py_XDECREF
  • 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:

    assignee = None
    closed_at = <Date 2011-02-04.20:30:43.927>
    created_at = <Date 2011-02-04.01:26:08.290>
    labels = ['extension-modules', 'release-blocker']
    title = 'Py_DECREF->Py_XDECREF in Module/_sqlite/module.c'
    updated_at = <Date 2011-02-04.20:30:43.926>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2011-02-04.20:30:43.926>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-02-04.20:30:43.927>
    closer = 'brett.cannon'
    components = ['Extension Modules']
    creation = <Date 2011-02-04.01:26:08.290>
    creator = 'brett.cannon'
    dependencies = []
    files = ['20670']
    hgrepos = []
    issue_num = 11110
    keywords = ['patch']
    message_count = 4.0
    messages = ['127853', '127859', '127903', '127938']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'georg.brandl', 'belopolsky']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue11110'
    versions = ['Python 3.2']

    @brettcannon
    Copy link
    Member Author

    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;
         }

    @brettcannon brettcannon added release-blocker extension-modules C modules in the Modules dir labels Feb 4, 2011
    @abalkin
    Copy link
    Member

    abalkin commented Feb 4, 2011

    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;
         }

    @birkenfeld
    Copy link
    Member

    Either one of these fixes (I prefer Brett's since it's shorter) should make it into 3.2.

    @brettcannon
    Copy link
    Member Author

    py3k: r88337
    3.1: 88339
    2.7 (blocked): 88338

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir release-blocker
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants