@@ -1213,7 +1213,7 @@ static PyObject *read_row_from_packet(
12131213 PyObject * py_result = NULL ;
12141214 PyObject * py_item = NULL ;
12151215 PyObject * py_str = NULL ;
1216- char * end = NULL ;
1216+ char end = '\0' ;
12171217
12181218 int sign = 1 ;
12191219 int year = 0 ;
@@ -1240,7 +1240,7 @@ static PyObject *read_row_from_packet(
12401240 for (unsigned long i = 0 ; i < py_state -> n_cols ; i ++ ) {
12411241
12421242 read_length_coded_string (& data , & data_l , & out , & out_l , & is_null );
1243- end = & out [out_l ];
1243+ end = out [out_l ];
12441244
12451245 orig_out = out ;
12461246 orig_out_l = out_l ;
@@ -1283,17 +1283,21 @@ static PyObject *read_row_from_packet(
12831283 case MYSQL_TYPE_LONG :
12841284 case MYSQL_TYPE_LONGLONG :
12851285 case MYSQL_TYPE_INT24 :
1286+ if (data_l ) out [out_l ] = '\0' ;
12861287 if (py_state -> flags [i ] & MYSQL_FLAG_UNSIGNED ) {
1287- py_item = PyLong_FromUnsignedLongLong (strtoull (out , & end , 10 ));
1288+ py_item = PyLong_FromUnsignedLongLong (strtoull (out , NULL , 10 ));
12881289 } else {
1289- py_item = PyLong_FromLongLong (strtoll (out , & end , 10 ));
1290+ py_item = PyLong_FromLongLong (strtoll (out , NULL , 10 ));
12901291 }
1292+ if (data_l ) out [out_l ] = end ;
12911293 if (!py_item ) goto error ;
12921294 break ;
12931295
12941296 case MYSQL_TYPE_FLOAT :
12951297 case MYSQL_TYPE_DOUBLE :
1296- py_item = PyFloat_FromDouble (strtod (out , & end ));
1298+ if (data_l ) out [out_l ] = '\0' ;
1299+ py_item = PyFloat_FromDouble (strtod (out , NULL ));
1300+ if (data_l ) out [out_l ] = end ;
12971301 if (!py_item ) goto error ;
12981302 break ;
12991303
@@ -1425,9 +1429,10 @@ static PyObject *read_row_from_packet(
14251429 goto error ;
14261430 break ;
14271431 }
1428- end = & out [out_l ];
1429- year = strtoul (out , & end , 10 );
1432+ if ( data_l ) out [out_l ] = '\0' ;
1433+ year = strtoul (out , NULL , 10 );
14301434 py_item = PyLong_FromLong (year );
1435+ if (data_l ) out [out_l ] = end ;
14311436 if (!py_item ) goto error ;
14321437 break ;
14331438
0 commit comments