Skip to content

Commit 26c985a

Browse files
committed
fix refleak in null-containing error case (python#21147)
1 parent d7324bc commit 26c985a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Modules/_sqlite/statement.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
7474
rc = PYSQLITE_SQL_WRONG_TYPE;
7575
return rc;
7676
}
77-
sql_cstr = PyString_AsString(sql_str);
77+
sql_cstr = PyString_AS_STRING(sql_str);
7878
if (strlen(sql_cstr) != (size_t)PyString_GET_SIZE(sql_str)) {
79+
Py_DECREF(sql_str);
7980
PyErr_SetString(PyExc_ValueError, "the query contains a null character");
8081
return PYSQLITE_SQL_WRONG_TYPE;
8182
}

0 commit comments

Comments
 (0)