Skip to content

Commit a9b583d

Browse files
gh-145202: Fix segfault in unicodedata.iter_graphemes during GC
1 parent f8ce51a commit a9b583d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a segmentation fault in :func:`unicodedata.iter_graphemes` when the iterator is deallocated after being cleared by the garbage collector.

Modules/unicodedata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ Segment_dealloc(PyObject *self)
19131913
{
19141914
PyTypeObject *tp = Py_TYPE(self);
19151915
PyObject_GC_UnTrack(self);
1916-
Py_DECREF(((SegmentObject *)self)->string);
1916+
Py_XDECREF(((SegmentObject *)self)->string);
19171917
tp->tp_free(self);
19181918
Py_DECREF(tp);
19191919
}
@@ -1989,7 +1989,7 @@ GBI_dealloc(PyObject *self)
19891989
{
19901990
PyTypeObject *tp = Py_TYPE(self);
19911991
PyObject_GC_UnTrack(self);
1992-
Py_DECREF(((GraphemeBreakIterator *)self)->iter.str);
1992+
Py_XDECREF(((GraphemeBreakIterator *)self)->iter.str);
19931993
tp->tp_free(self);
19941994
Py_DECREF(tp);
19951995
}

0 commit comments

Comments
 (0)