summaryrefslogtreecommitdiffstats
path: root/Objects/obmalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-05-02 21:26:03 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-05-02 21:26:03 (GMT)
commitaf8fc645af1db75a26e9f2e5ad48812a1dc2ee12 (patch)
tree22097cfc515975cd0132d876774e007c57489102 /Objects/obmalloc.c
parentdb067af12a5ebb889874e47d8177f9c4a3dc9a68 (diff)
downloadcpython-af8fc645af1db75a26e9f2e5ad48812a1dc2ee12.zip
cpython-af8fc645af1db75a26e9f2e5ad48812a1dc2ee12.tar.gz
cpython-af8fc645af1db75a26e9f2e5ad48812a1dc2ee12.tar.bz2
Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to
redirect.
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r--Objects/obmalloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 9fd7b31..e16a1db 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();
/*