mirror of
https://github.com/python/cpython.git
synced 2025-09-01 06:28:36 +00:00
sqlite: raise an OverflowError if the result is longer than INT_MAX bytes
Fix a compiler warning on Windows 64-bit
This commit is contained in:
parent
74387f5cac
commit
83ed42bfbf
1 changed files with 8 additions and 2 deletions
|
@ -522,10 +522,16 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
|
||||||
const char* buffer;
|
const char* buffer;
|
||||||
Py_ssize_t buflen;
|
Py_ssize_t buflen;
|
||||||
if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
|
if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
"could not convert BLOB to buffer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sqlite3_result_blob(context, buffer, buflen, SQLITE_TRANSIENT);
|
if (buflen > INT_MAX) {
|
||||||
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
"BLOB longer than INT_MAX bytes");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sqlite3_result_blob(context, buffer, (int)buflen, SQLITE_TRANSIENT);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue