This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Oren Milman
Recipients Oren Milman
Date 2017-10-09.13:54:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507557245.08.0.213398074469.issue31734@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes a crash:
import sqlite3
cache = sqlite3.Cache.__new__(sqlite3.Cache)
cache.get(None)

This is because pysqlite_cache_get() (in Modules/_sqlite/cache.c) assumes that
the Cache object is initialized, and so it passes self->mapping to
PyDict_GetItem(), which assumes it is not NULL, and crashes.


Also, the following code causes a SystemError ('null argument to internal
routine'), as well as refleaks in the deallocation of the Cache object:
import sqlite3
cache = sqlite3.Cache(str)
try:
    cache.__init__()
except TypeError:
    pass
cache.get(None)

This is because pysqlite_cache_init() first sets self->factory to NULL, and
only then parses its arguments, so in case it fails to parse the arguments
(e.g. due to a wrong number of arguments) we are left with a partially
initialized Cache object.


While we are here, we should also fix refleaks that occur when
sqlite3.Cache.__init__() is called more than once.
History
Date User Action Args
2017-10-09 13:54:05Oren Milmansetrecipients: + Oren Milman
2017-10-09 13:54:05Oren Milmansetmessageid: <1507557245.08.0.213398074469.issue31734@psf.upfronthosting.co.za>
2017-10-09 13:54:05Oren Milmanlinkissue31734 messages
2017-10-09 13:54:04Oren Milmancreate