Skip to content

Commit cc33b50

Browse files
committed
BUG29909157: Table scans of floats causes memory leak with the C extension
This patch fixes a memory leak when fetching float values with the C extension.
1 parent 59ee210 commit cc33b50

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/mysql_capi.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,15 +2562,18 @@ MySQL_fetch_row(MySQL *self)
25622562
else if (field_type == MYSQL_TYPE_FLOAT ||
25632563
field_type == MYSQL_TYPE_DOUBLE)
25642564
{
2565-
#ifdef PY3
2566-
value= PyFloat_FromString(PyStringFromString(row[i]));
2567-
#else
2568-
value= PyFloat_FromString(PyStringFromString(row[i]), NULL);
2569-
#endif
2570-
if (!value)
2565+
char *end;
2566+
double val= PyOS_string_to_double(row[i], &end, NULL);
2567+
2568+
if (*end == '\0')
2569+
{
2570+
value= PyFloat_FromDouble(val);
2571+
}
2572+
else
25712573
{
25722574
value= Py_None;
25732575
}
2576+
25742577
PyTuple_SET_ITEM(result_row, i, value);
25752578
}
25762579
else if (field_type == MYSQL_TYPE_BIT)

0 commit comments

Comments
 (0)