Skip to content

Commit 9c6d577

Browse files
committed
respect encoded length when reading integer
1 parent dce65e9 commit 9c6d577

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

singlestoredb/mysql/accel.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,14 +1283,19 @@ static PyObject *read_row_from_packet(
12831283
case MYSQL_TYPE_LONG:
12841284
case MYSQL_TYPE_LONGLONG:
12851285
case MYSQL_TYPE_INT24:
1286+
{
1287+
char *substr = calloc(out_l + 1, sizeof(char));
1288+
memcpy(substr, out, out_l);
12861289
if (py_state->flags[i] & MYSQL_FLAG_UNSIGNED) {
1287-
py_item = PyLong_FromUnsignedLongLong(strtoull(out, &end, 10));
1290+
py_item = PyLong_FromUnsignedLongLong(strtoull(substr, NULL, 10));
12881291
} else {
1289-
py_item = PyLong_FromLongLong(strtoll(out, &end, 10));
1292+
py_item = PyLong_FromLongLong(strtoll(substr, NULL, 10));
12901293
}
1294+
DESTROY(substr);
1295+
out += out_l;
12911296
if (!py_item) goto error;
12921297
break;
1293-
1298+
}
12941299
case MYSQL_TYPE_FLOAT:
12951300
case MYSQL_TYPE_DOUBLE:
12961301
py_item = PyFloat_FromDouble(strtod(out, &end));

0 commit comments

Comments
 (0)