$OpenBSD: patch-Objects_bufferobject_c,v 1.1 2008/08/06 03:23:31 djm Exp $ --- Objects/bufferobject.c.orig Thu Feb 14 22:26:18 2008 +++ Objects/bufferobject.c Tue Aug 5 18:18:52 2008 @@ -427,6 +427,10 @@ buffer_repeat(PyBufferObject *self, Py_ssize_t count) count = 0; if (!get_buf(self, &ptr, &size, ANY_BUFFER)) return NULL; + if (count > PY_SSIZE_T_MAX / size) { + PyErr_SetString(PyExc_MemoryError, "result too large"); + return NULL; + } ob = PyString_FromStringAndSize(NULL, size * count); if ( ob == NULL ) return NULL;