diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h index deebfeadc0f4fd..fe460d41f6700f 100644 --- a/Objects/stringlib/join.h +++ b/Objects/stringlib/join.h @@ -72,11 +72,11 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) drops the sequence's last reference to it. */ Py_INCREF(item); if (PyObject_GetBuffer(item, &buffers[i], PyBUF_SIMPLE) != 0) { - Py_DECREF(item); PyErr_Format(PyExc_TypeError, "sequence item %zd: expected a bytes-like object, " "%.80s found", i, Py_TYPE(item)->tp_name); + Py_DECREF(item); goto error; } Py_DECREF(item); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e0464fe6475cfd..43a3969c43db5d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -11327,6 +11327,7 @@ slot_bf_getbuffer(PyObject *self, Py_buffer *buffer, int flags) wrapper = PyObject_GC_New(PyBufferWrapper, &_PyBufferWrapper_Type); if (wrapper == NULL) { + PyBuffer_Release(buffer); goto fail; } wrapper->mv = ret;