FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-145376: Fix various refleaks Objects/ by eendebakpt · Pull Request #145609 · python/cpython · GitHub

Repository navigation

Merged
5 changes: 5 additions & 0 deletions Modules/_cursesmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,13 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "addstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_XDECREF(bytesobj);
return NULL;
}
}
#ifdef HAVE_NCURSESW
if (strtype == 2) {
assert(bytesobj == NULL);
if (use_xy) {
rtn = mvwaddwstr(self->win,y,x,wstr);
funcname = "mvwaddwstr";
Expand All @@ -1130,6 +1132,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
else
#endif
{
assert(wstr == NULL);
const char *str = PyBytes_AS_STRING(bytesobj);
if (use_xy) {
rtn = mvwaddstr(self->win,y,x,str);
Expand Down Expand Up @@ -1210,6 +1213,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "addnstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_XDECREF(bytesobj);
return NULL;
}
}
Expand Down Expand Up @@ -2212,6 +2216,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "insstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_XDECREF(bytesobj);
return NULL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/binascii.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
}
unsigned char *bin_data = PyBytesWriter_GetData(writer);
if (bin_data == NULL) {
return NULL;
goto error;
}

uint32_t leftchar = 0;
Expand Down
3 changes: 3 additions & 0 deletions Objects/genericaliasobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ subs_tvars(PyObject *obj, PyObject *params,
&PyTuple_GET_ITEM(arg, 0),
PyTuple_GET_SIZE(arg));
if (j < 0) {
Py_DECREF(subparams);
Py_DECREF(subargs);
return NULL;
}
continue;
Expand Down Expand Up @@ -455,6 +457,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
if (is_args_list) {
args = tuple_args = PySequence_Tuple(args);
if (args == NULL) {
Py_DECREF(item);
return NULL;
}
}
Expand Down
5 changes: 3 additions & 2 deletions Objects/object.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ _PyObject_SetAttributeErrorContext(PyObject* v, PyObject* name)
// Augment the exception with the name and object
if (PyObject_SetAttr(exc, &_Py_ID(name), name) ||
PyObject_SetAttr(exc, &_Py_ID(obj), v)) {
Py_DECREF(exc);
return 1;
}
restore:
Expand Down Expand Up @@ -3077,9 +3078,9 @@ Py_ReprEnter(PyObject *obj)
list = PyList_New(0);
if (list == NULL)
return -1;
if (PyDict_SetItem(dict, &_Py_ID(Py_Repr), list) < 0)
if (_PyDict_SetItem_Take2((PyDictObject *)dict, &_Py_ID(Py_Repr), list) < 0) {
return -1;
Py_DECREF(list);
}
}
i = PyList_GET_SIZE(list);
while (--i >= 0) {
Expand Down
3 changes: 2 additions & 1 deletion Objects/structseq.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ initialize_structseq_dict(PyStructSequence_Desc *desc, PyObject* dict,
}

if (_PyTuple_Resize(&keys, k) == -1) {
goto error;
assert(keys == NULL);
return -1;
}

if (PyDict_SetItemString(dict, match_args_key, keys) < 0) {
Expand Down
3 changes: 1 addition & 2 deletions Objects/typevarobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2305,13 +2305,12 @@ generic_class_getitem(PyObject *cls, PyObject *args, PyObject *kwargs)
PyObject *
_Py_subscript_generic(PyThreadState* unused, PyObject *params)
{
params = unpack_typevartuples(params);

PyInterpreterState *interp = _PyInterpreterState_GET();
if (interp->cached_objects.generic_type == NULL) {
PyErr_SetString(PyExc_SystemError, "Cannot find Generic type");
return NULL;
}
params = unpack_typevartuples(params);
PyObject *args[2] = {(PyObject *)interp->cached_objects.generic_type, params};
PyObject *result = call_typing_func_object("_GenericAlias", args, 2);
Py_DECREF(params);
Expand Down
2 changes: 1 addition & 1 deletion Objects/unicodeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5220,7 +5220,7 @@ unicode_decode_utf8_impl(_PyUnicodeWriter *writer,
}

if (_PyUnicodeWriter_Prepare(writer, end - s, 127) < 0) {
return -1;
goto onError;
}
}
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL