File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -1270,7 +1270,9 @@ pycall_libpython_helpers_m_str(VALUE mod, VALUE pyptr)
1270
1270
pycall_pyerror_fetch_and_raise ("PyObject_Str" );
1271
1271
}
1272
1272
1273
- return pycall_pyobject_to_ruby (pyobj_str );
1273
+ VALUE v = pycall_pyobject_to_ruby (pyobj_str );
1274
+ pycall_Py_DecRef (pyobj_str );
1275
+ return v ;
1274
1276
}
1275
1277
1276
1278
static VALUE
@@ -1690,19 +1692,21 @@ pycall_pyunicode_to_ruby(PyObject *pyobj)
1690
1692
return Qnil ;
1691
1693
}
1692
1694
1693
- pyobj = Py_API (PyUnicode_AsUTF8String )(pyobj );
1694
- if (!pyobj ) {
1695
+ PyObject * pyobj_uni = Py_API (PyUnicode_AsUTF8String )(pyobj );
1696
+ if (!pyobj_uni ) {
1695
1697
Py_API (PyErr_Clear )();
1696
1698
return Qnil ;
1697
1699
}
1698
1700
1699
- res = Py_API (PyString_AsStringAndSize )(pyobj , & str , & len );
1701
+ res = Py_API (PyString_AsStringAndSize )(pyobj_uni , & str , & len );
1700
1702
if (res < 0 ) {
1701
- pycall_Py_DecRef (pyobj );
1703
+ pycall_Py_DecRef (pyobj_uni );
1702
1704
return Qnil ;
1703
1705
}
1704
1706
1705
- return rb_enc_str_new (str , len , rb_enc_from_index (rb_utf8_encindex ()));
1707
+ VALUE v = rb_enc_str_new (str , len , rb_enc_from_index (rb_utf8_encindex ()));
1708
+ pycall_Py_DecRef (pyobj_uni );
1709
+ return v ;
1706
1710
}
1707
1711
1708
1712
static VALUE
You can’t perform that action at this time.
0 commit comments