File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -519,10 +519,15 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
519
519
} else if (PyFloat_Check (py_val )) {
520
520
sqlite3_result_double (context , PyFloat_AsDouble (py_val ));
521
521
} else if (PyUnicode_Check (py_val )) {
522
- const char * str = PyUnicode_AsUTF8 (py_val );
523
- if (str == NULL )
522
+ Py_ssize_t sz ;
523
+ const char * str = PyUnicode_AsUTF8AndSize (py_val , & sz );
524
+ if (str == NULL ) {
524
525
return -1 ;
525
- sqlite3_result_text (context , str , -1 , SQLITE_TRANSIENT );
526
+ }
527
+ if (sz > INT_MAX ) {
528
+ sz = -1 ; // Let SQLite compute string length
529
+ }
530
+ sqlite3_result_text (context , str , (int )sz , SQLITE_TRANSIENT );
526
531
} else if (PyObject_CheckBuffer (py_val )) {
527
532
Py_buffer view ;
528
533
if (PyObject_GetBuffer (py_val , & view , PyBUF_SIMPLE ) != 0 ) {
You can’t perform that action at this time.
0 commit comments