summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/connection.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 01:27:23 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 01:27:23 (GMT)
commit8699950b04343afe37e9dcdce87028ba0f56827b (patch)
treeeae09cfadd1474a6cdb5a5b23f8d0bf03ae239c2 /Modules/_sqlite/connection.c
parentf6c578328c419f25dea91425479a6ceeb891b04d (diff)
downloadcpython-8699950b04343afe37e9dcdce87028ba0f56827b.zip
cpython-8699950b04343afe37e9dcdce87028ba0f56827b.tar.gz
cpython-8699950b04343afe37e9dcdce87028ba0f56827b.tar.bz2
Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
Strip also some trailing spaces
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r--Modules/_sqlite/connection.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 88d6b40..184bdee 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -3,7 +3,7 @@
* Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
*
* This file is part of pysqlite.
- *
+ *
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
@@ -495,7 +495,9 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
} else if (PyFloat_Check(py_val)) {
sqlite3_result_double(context, PyFloat_AsDouble(py_val));
} else if (PyUnicode_Check(py_val)) {
- sqlite3_result_text(context, _PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);
+ char *str = _PyUnicode_AsString(py_val);
+ if (str != NULL)
+ sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT);
} else if (PyObject_CheckBuffer(py_val)) {
if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
@@ -892,7 +894,7 @@ static int _progress_handler(void* user_arg)
}
/* abort query if error occurred */
- rc = 1;
+ rc = 1;
} else {
rc = (int)PyObject_IsTrue(ret);
Py_DECREF(ret);