Skip to content

Commit c332912

Browse files
committed
Fix flag array size computation
1 parent 1aed281 commit c332912

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/flowgraph.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,8 +2544,8 @@ optimize_load_fast(cfg_builder *g)
25442544
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
25452545
max_instrs = Py_MAX(max_instrs, b->b_iused);
25462546
}
2547-
size_t instr_flags_size = max_instrs * sizeof(bool);
2548-
uint8_t *instr_flags = PyMem_Calloc(max_instrs, instr_flags_size);
2547+
size_t instr_flags_size = max_instrs * sizeof(uint8_t);
2548+
uint8_t *instr_flags = PyMem_Malloc(instr_flags_size);
25492549
if (instr_flags == NULL) {
25502550
PyErr_NoMemory();
25512551
return ERROR;
@@ -2566,7 +2566,7 @@ optimize_load_fast(cfg_builder *g)
25662566
assert(block->b_startdepth > -1);
25672567

25682568
// Reset per-block state.
2569-
memset(instr_flags, 0, instr_flags_size);
2569+
memset(instr_flags, 0, block->b_iused * sizeof(*instr_flags));
25702570

25712571
// Reset the stack of refs. We don't track references on the stack
25722572
// across basic blocks, but the bytecode will expect their

0 commit comments

Comments
 (0)