Skip to content

Commit 692778a

Browse files
committed
BUG31335275: Fix memory leak when using the Decimal data type
This patch fixes a memory leak in the C extension when using the Decimal data type.
1 parent 5da04e9 commit 692778a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/mysql_capi_conversion.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,11 @@ PyObject*
701701
pytomy_decimal(PyObject *obj)
702702
{
703703
#ifdef PY3
704-
return PyBytes_FromString((const char *)PyUnicode_1BYTE_DATA(
705-
PyObject_Str(obj)));
704+
PyObject *str= PyObject_Str(obj);
705+
PyObject *tmp= (const char *)PyUnicode_1BYTE_DATA(str);
706+
PyObject *ret= PyBytes_FromString(tmp);
707+
Py_DECREF(tmp);
708+
return ret;
706709
#else
707710
PyObject *numeric, *new_num;
708711
int tmp_size;

0 commit comments

Comments
 (0)