diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-17 23:52:05 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-17 23:52:05 +0100 |
commit | 6bca8f9042434a875eb68110a0ed83f5413ba222 (patch) | |
tree | 95a662642d6854cc994b75eb1d1f66fe88441362 /Python/pyarena.c | |
parent | 77446a753a07d0e24d9f18b6128489eece818eb8 (diff) | |
parent | 07782060a9f86202c63857c4e2db73724dc5dc10 (diff) | |
download | cpython-6bca8f9042434a875eb68110a0ed83f5413ba222.tar.gz |
Issue #16408: Fix file descriptors not being closed in error conditions in the zipfile module.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Python/pyarena.c')
-rw-r--r-- | Python/pyarena.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Python/pyarena.c b/Python/pyarena.c index 5a255ae497..bb2fd1e42a 100644 --- a/Python/pyarena.c +++ b/Python/pyarena.c @@ -12,8 +12,6 @@ #define DEFAULT_BLOCK_SIZE 8192 #define ALIGNMENT 8 -#define ALIGNMENT_MASK (ALIGNMENT - 1) -#define ROUNDUP(x) (((x) + ALIGNMENT_MASK) & ~ALIGNMENT_MASK) typedef struct _block { /* Total number of bytes owned by this block available to pass out. @@ -85,8 +83,8 @@ block_new(size_t size) b->ab_size = size; b->ab_mem = (void *)(b + 1); b->ab_next = NULL; - b->ab_offset = ROUNDUP((Py_uintptr_t)(b->ab_mem)) - - (Py_uintptr_t)(b->ab_mem); + b->ab_offset = (char *)_Py_ALIGN_UP(b->ab_mem, ALIGNMENT) - + (char *)(b->ab_mem); return b; } @@ -104,7 +102,7 @@ block_alloc(block *b, size_t size) { void *p; assert(b); - size = ROUNDUP(size); + size = _Py_SIZE_ROUND_UP(size, ALIGNMENT); if (b->ab_offset + size > b->ab_size) { /* If we need to allocate more memory than will fit in the default block, allocate a one-off block that is |