cpython/Modules/_sre
Bernát Gábor c79e18a8e5
gh-150717: Avoid mark-array allocation for groupless regex patterns (GH-150719)
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.
2026-06-02 10:45:30 +03:00
..
clinic gh-86519: Add prefixmatch APIs to the re module (GH-31137) 2026-02-15 17:43:39 -08:00
sre.c gh-150717: Avoid mark-array allocation for groupless regex patterns (GH-150719) 2026-06-02 10:45:30 +03:00
sre.h gh-67877: Fix memory leaks in terminated RE matching (GH-126840) 2024-11-18 11:53:45 +02:00
sre_constants.h gh-105687: Remove deprecated objects from re module (#105688) 2023-06-14 12:26:20 +02:00
sre_lib.h gh-124130: Fix a bug in matching regular expression \B in empty string (GH-127007) 2025-01-02 12:11:21 +00:00
sre_targets.h gh-97669: Create Tools/build/ directory (#97963) 2022-10-17 12:01:00 +02:00