mirror of
https://github.com/python/cpython
synced 2024-09-16 00:27:20 +00:00
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).
This commit is contained in:
parent
a00c3fd12d
commit
06bb4873d6
|
@ -1227,10 +1227,7 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
|
||||||
|
|
||||||
_Py_AllocatedBlocks++;
|
_Py_AllocatedBlocks++;
|
||||||
|
|
||||||
if (nelem == 0 || elsize == 0)
|
assert(elsize == 0 || nelem <= PY_SSIZE_T_MAX / elsize);
|
||||||
goto redirect;
|
|
||||||
|
|
||||||
assert(nelem <= PY_SSIZE_T_MAX / elsize);
|
|
||||||
nbytes = nelem * elsize;
|
nbytes = nelem * elsize;
|
||||||
|
|
||||||
#ifdef WITH_VALGRIND
|
#ifdef WITH_VALGRIND
|
||||||
|
@ -1240,6 +1237,9 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
|
||||||
goto redirect;
|
goto redirect;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (nelem == 0 || elsize == 0)
|
||||||
|
goto redirect;
|
||||||
|
|
||||||
if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
|
if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
|
||||||
LOCK();
|
LOCK();
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue