@@ -135,7 +135,6 @@ pysqlite_build_row_cast_map(pysqlite_Cursor* self)
135
135
{
136
136
int i ;
137
137
const char * pos ;
138
- const char * colname ;
139
138
const char * decltype ;
140
139
PyObject * converter ;
141
140
@@ -152,21 +151,24 @@ pysqlite_build_row_cast_map(pysqlite_Cursor* self)
152
151
converter = NULL ;
153
152
154
153
if (self -> connection -> detect_types & PARSE_COLNAMES ) {
155
- colname = sqlite3_column_name (self -> statement -> st , i );
156
- if (colname ) {
157
- const char * type_start = NULL ;
158
- for (pos = colname ; * pos != 0 ; pos ++ ) {
159
- if (* pos == '[' ) {
160
- type_start = pos + 1 ;
161
- }
162
- else if (* pos == ']' && type_start != NULL ) {
163
- converter = _pysqlite_get_converter (type_start , pos - type_start );
164
- if (!converter && PyErr_Occurred ()) {
165
- Py_CLEAR (self -> row_cast_map );
166
- return -1 ;
167
- }
168
- break ;
154
+ const char * colname = sqlite3_column_name (self -> statement -> st , i );
155
+ if (colname == NULL ) {
156
+ PyErr_NoMemory ();
157
+ Py_CLEAR (self -> row_cast_map );
158
+ return -1 ;
159
+ }
160
+ const char * type_start = NULL ;
161
+ for (pos = colname ; * pos != 0 ; pos ++ ) {
162
+ if (* pos == '[' ) {
163
+ type_start = pos + 1 ;
164
+ }
165
+ else if (* pos == ']' && type_start != NULL ) {
166
+ converter = _pysqlite_get_converter (type_start , pos - type_start );
167
+ if (!converter && PyErr_Occurred ()) {
168
+ Py_CLEAR (self -> row_cast_map );
169
+ return -1 ;
169
170
}
171
+ break ;
170
172
}
171
173
}
172
174
}
@@ -210,10 +212,6 @@ _pysqlite_build_column_name(pysqlite_Cursor *self, const char *colname)
210
212
const char * pos ;
211
213
Py_ssize_t len ;
212
214
213
- if (!colname ) {
214
- Py_RETURN_NONE ;
215
- }
216
-
217
215
if (self -> connection -> detect_types & PARSE_COLNAMES ) {
218
216
for (pos = colname ; * pos ; pos ++ ) {
219
217
if (* pos == '[' ) {
@@ -311,8 +309,9 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
311
309
if (!converted && PyErr_ExceptionMatches (PyExc_UnicodeDecodeError )) {
312
310
PyErr_Clear ();
313
311
colname = sqlite3_column_name (self -> statement -> st , i );
314
- if (!colname ) {
315
- colname = "<unknown column name>" ;
312
+ if (colname == NULL ) {
313
+ PyErr_NoMemory ();
314
+ goto error ;
316
315
}
317
316
PyOS_snprintf (buf , sizeof (buf ) - 1 , "Could not decode to UTF-8 column '%s' with text '%s'" ,
318
317
colname , text );
@@ -550,9 +549,15 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
550
549
if (!descriptor ) {
551
550
goto error ;
552
551
}
553
- column_name = _pysqlite_build_column_name (self ,
554
- sqlite3_column_name (self -> statement -> st , i ));
555
- if (!column_name ) {
552
+ const char * colname ;
553
+ colname = sqlite3_column_name (self -> statement -> st , i );
554
+ if (colname == NULL ) {
555
+ PyErr_NoMemory ();
556
+ Py_DECREF (descriptor );
557
+ goto error ;
558
+ }
559
+ column_name = _pysqlite_build_column_name (self , colname );
560
+ if (column_name == NULL ) {
556
561
Py_DECREF (descriptor );
557
562
goto error ;
558
563
}
0 commit comments