From: Victor Stinner Date: Fri, 2 May 2014 21:26:03 +0000 (+0200) Subject: Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to X-Git-Tag: v3.5.0a1~1748 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af8fc645af1db75a26e9f2e5ad48812a1dc2ee12;p=thirdparty%2FPython%2Fcpython.git Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to redirect. --- diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 9fd7b31c8637..e16a1db808d5 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1183,12 +1183,12 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) goto redirect; #endif - if (nelem == 0 || elsize == 0) - goto redirect; - assert(nelem <= PY_SSIZE_T_MAX / elsize); nbytes = nelem * elsize; + if (nelem == 0 || elsize == 0) + goto redirect; + if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) { LOCK(); /*