Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/flint/types/_gr.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cimport cython
cimport libc.stdlib

from flint.flintlib.functions.flint cimport (
flint_free,
)

from flint.flintlib.types.flint cimport (
slong,
ulong,
Expand Down Expand Up @@ -296,9 +300,10 @@ cdef class gr_ctx(flint_ctx):
err = gr_get_str(&s, val.pval, self.ctx_t)
if err != GR_SUCCESS:
raise self._error(err, "Failed to convert to string")
py_str = (<bytes>s).decode("utf-8")
# XXX: Is this a memory leak?
# flint_free(s)
try:
py_str = (<bytes>s).decode("utf-8")
finally:
flint_free(s)
return py_str

@cython.final
Expand Down