New submission from Erlend Egeberg Aasland <[email protected]>:
If the connection factory __init__ method fails, we hit a seg. fault when
pysqlite_do_all_statements() is called to clean up the defect connection:
PyList_Size received a NULL pointer.
Suggested fix:
Split pysqlite_do_all_statements() in two: one function for resetting cursors,
and one for resetting/finalising statements. In each function, check if the
respective lists are NULL pointers before iterating. See attached proposed
patch.
Test:
def test_invalid_connection_factory(self):
class DefectFactory(sqlite.Connection):
def __init__(self, *args, **kwargs):
return None
self.con = sqlite.connect(":memory:", factory=DefectFactory)
----------
components: Library (Lib)
files: patch.diff
keywords: patch
messages: 388082
nosy: berker.peksag, erlendaasland, serhiy.storchaka
priority: normal
severity: normal
status: open
title: [sqlite3] sqlite3.connect() segfaults if given a faulty Connection
factory
type: crash
versions: Python 3.10
Added file: https://bugs.python.org/file49850/patch.diff
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43398>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com