Backport 52505:
Prevent crash if alloc of garbage fails.  Found by Typo.pl.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 7afea12..739a571 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2606,6 +2606,11 @@
 
 			garbage = (PyObject**)
 				PyMem_MALLOC(slicelength*sizeof(PyObject*));
+			if (!garbage) {
+				Py_DECREF(seq);
+				PyErr_NoMemory();
+				return -1;
+			}
 
 			selfitems = self->ob_item;
 			seqitems = PySequence_Fast_ITEMS(seq);