gh-111178: fix UBSan failures in Modules/_sqlite (GH-129087)

* fix UBSan failures for `pysqlite_Blob`
* fix UBSan failures for `pysqlite_Connection`
* fix UBSan failures for `pysqlite_Cursor`
* fix UBSan failures for `pysqlite_PrepareProtocol`
* fix UBSan failures for `pysqlite_Row`
* fix UBSan failures for `pysqlite_Statement`

* suppress unused return values
This commit is contained in:
Bénédikt Tran 2025-01-31 14:33:30 +01:00 committed by GitHub
parent 9d63ae5fe5
commit 881984b41a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 101 additions and 55 deletions

View file

@ -25,6 +25,8 @@
#include "statement.h"
#include "util.h"
#define _pysqlite_Statement_CAST(op) ((pysqlite_Statement *)(op))
/* prototypes */
static const char *lstrip_sql(const char *sql);
@ -99,10 +101,11 @@ error:
}
static void
stmt_dealloc(pysqlite_Statement *self)
stmt_dealloc(PyObject *op)
{
pysqlite_Statement *self = _pysqlite_Statement_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
PyObject_GC_UnTrack(op);
if (self->st) {
Py_BEGIN_ALLOW_THREADS
sqlite3_finalize(self->st);
@ -114,7 +117,7 @@ stmt_dealloc(pysqlite_Statement *self)
}
static int
stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
stmt_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
return 0;