Skip to content

Commit

Permalink
fix refleaks
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Mar 23, 2024
1 parent 1c385a3 commit 2a88022
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -7767,10 +7767,14 @@ _PyType_SharedKeysMaxSize(PyTypeObject *type)
PyObject *attrs = PyObject_GetAttr((PyObject*)type, &_Py_ID(__expected_attributes__));
if (attrs != NULL && PyTuple_Check(attrs)) {
Py_ssize_t num_keys = PyTuple_GET_SIZE(attrs);
Py_DECREF(attrs);
if (num_keys > SHARED_KEYS_MAX_SIZE) {
return 1 + num_keys;
}
}
else {
Py_XDECREF(attrs);
}
}
return SHARED_KEYS_MAX_SIZE;
}
Expand Down
1 change: 1 addition & 0 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,7 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno)
return ERROR;
}
ADDOP_LOAD_CONST(c, NO_LOCATION, expected_attributes);
Py_CLEAR(expected_attributes);
if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__expected_attributes__), Store) < 0) {
compiler_exit_scope(c);
return ERROR;
Expand Down

0 comments on commit 2a88022

Please sign in to comment.