Fix MemoryError caused by moving around code in PR #886; nbytes was sometimes used unitinitalized (in non-debug builds, when use_calloc was false and elsize was 0).
_Py_AllocatedBlocks++;
- if (nelem == 0 || elsize == 0)
- goto redirect;
-
- assert(nelem <= PY_SSIZE_T_MAX / elsize);
+ assert(elsize == 0 || nelem <= PY_SSIZE_T_MAX / elsize);
nbytes = nelem * elsize;
#ifdef WITH_VALGRIND
goto redirect;
#endif
+ if (nelem == 0 || elsize == 0)
+ goto redirect;
+
if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
LOCK();
/*