Skip to content

Commit 05cf606

Browse files
committed
Add PyObject_GC_Track
1 parent a794ebe commit 05cf606

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Modules/_decimal/_decimal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,12 @@ context_new(PyTypeObject *type, PyObject *args UNUSED, PyObject *kwds UNUSED)
13741374
SdFlagAddr(self->flags) = &ctx->status;
13751375

13761376
CtxCaps(self) = 1;
1377+
13771378
self->tstate = NULL;
1379+
// If this statement is added, a segfault will be raised.
1380+
if (type == state->PyDecContext_Type) {
1381+
PyObject_GC_Track(self);
1382+
}
13781383

13791384
return (PyObject *)self;
13801385
}
@@ -2024,6 +2029,10 @@ PyDecType_New(PyTypeObject *type)
20242029
MPD(dec)->alloc = _Py_DEC_MINALLOC;
20252030
MPD(dec)->data = dec->data;
20262031

2032+
if (type == state->PyDec_Type) {
2033+
PyObject_GC_Track(dec);
2034+
}
2035+
20272036
return (PyObject *)dec;
20282037
}
20292038
#define dec_alloc(st) PyDecType_New((st)->PyDec_Type)

0 commit comments

Comments
 (0)