mirror of
https://github.com/python/cpython.git
synced 2026-06-05 01:10:53 +00:00
state_init() always did PyMem_New(state->mark, groups*2), which for a pattern with no capturing groups is PyMem_Malloc(0) -- a real allocation (plus matching free) on every match/search/fullmatch call, for an array that is never read: groupless patterns emit no MARK opcodes and group 0's span is taken from state->start/ptr. Guard the allocation with `if (pattern->groups)`. state->mark stays NULL (set by the preceding memset), and both the error path and state_fini already PyMem_Free(NULL) safely. |
||
|---|---|---|
| .. | ||
| clinic | ||
| sre.c | ||
| sre.h | ||
| sre_constants.h | ||
| sre_lib.h | ||
| sre_targets.h | ||