@@ -1267,6 +1267,10 @@ static PyObject *read_row_from_packet(
12671267
12681268 // If no converter was passed in, do the default processing.
12691269 else {
1270+ // Make sure not to overrun
1271+ char tmp = * end ;
1272+ if (data_l ) * end = '\0' ;
1273+
12701274 switch (py_state -> type_codes [i ]) {
12711275 case MYSQL_TYPE_NEWDECIMAL :
12721276 case MYSQL_TYPE_DECIMAL :
@@ -1283,19 +1287,13 @@ static PyObject *read_row_from_packet(
12831287 case MYSQL_TYPE_LONG :
12841288 case MYSQL_TYPE_LONGLONG :
12851289 case MYSQL_TYPE_INT24 :
1286- {
1287- char * substr = calloc (out_l + 1 , sizeof (char ));
1288- memcpy (substr , out , out_l );
12891290 if (py_state -> flags [i ] & MYSQL_FLAG_UNSIGNED ) {
1290- py_item = PyLong_FromUnsignedLongLong (strtoull (substr , NULL , 10 ));
1291+ py_item = PyLong_FromUnsignedLongLong (strtoull (out , NULL , 10 ));
12911292 } else {
1292- py_item = PyLong_FromLongLong (strtoll (substr , NULL , 10 ));
1293+ py_item = PyLong_FromLongLong (strtoll (out , NULL , 10 ));
12931294 }
1294- DESTROY (substr );
1295- out += out_l ;
12961295 if (!py_item ) goto error ;
12971296 break ;
1298- }
12991297 case MYSQL_TYPE_FLOAT :
13001298 case MYSQL_TYPE_DOUBLE :
13011299 py_item = PyFloat_FromDouble (strtod (out , & end ));
@@ -1430,8 +1428,7 @@ static PyObject *read_row_from_packet(
14301428 goto error ;
14311429 break ;
14321430 }
1433- end = & out [out_l ];
1434- year = strtoul (out , & end , 10 );
1431+ year = strtoul (out , NULL , 10 );
14351432 py_item = PyLong_FromLong (year );
14361433 if (!py_item ) goto error ;
14371434 break ;
@@ -1472,6 +1469,7 @@ static PyObject *read_row_from_packet(
14721469 py_state -> type_codes [i ], NULL );
14731470 goto error ;
14741471 }
1472+ if (data_l ) * end = tmp ;
14751473 }
14761474 }
14771475
0 commit comments