summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/interpreteridobject.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c
index 39bde97..4623910 100644
--- a/Objects/interpreteridobject.c
+++ b/Objects/interpreteridobject.c
@@ -24,15 +24,21 @@ newinterpid(PyTypeObject *cls, int64_t id, int force)
}
}
+ if (interp != NULL) {
+ if (_PyInterpreterState_IDIncref(interp) < 0) {
+ return NULL;
+ }
+ }
+
interpid *self = PyObject_New(interpid, cls);
if (self == NULL) {
+ if (interp != NULL) {
+ _PyInterpreterState_IDDecref(interp);
+ }
return NULL;
}
self->id = id;
- if (interp != NULL) {
- _PyInterpreterState_IDIncref(interp);
- }
return self;
}