Skip to content

Commit eec5fa1

Browse files
committed
Fixed string to decimal conversion for binary protocol.
1 parent c150975 commit eec5fa1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mariadb_codecs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,14 @@ field_fetch_callback(void *data, unsigned int column, unsigned char **row)
697697

698698
if (length > 0)
699699
{
700-
self->values[column]= PyObject_CallFunction(decimal_type, "s", (const char *)*row);
700+
char *tmp= alloca(length + 1);
701+
memcpy(tmp, (const char *)*row, length);
702+
tmp[length]= 0;
703+
self->values[column]= PyObject_CallFunction(decimal_type, "s", tmp);
701704
} else {
702705
self->values[column]= PyObject_CallFunction(decimal_type, "s", "0");
703706
}
707+
*row+= length;
704708
break;
705709
}
706710
case MYSQL_TYPE_GEOMETRY:

0 commit comments

Comments
 (0)