Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
_sre.template crashes iftemplate argument contains group index that is negative or not anint instance.
Examples:
>>>import_sre>>>_sre.template("", ["",-1,""])Segmentationfault (coredumped)
>>>_sre.template("", ["", (),""])Segmentationfault (coredumped)
In_sre_template_impl part ofself->items remains uninitialized if call toPyLong_AsSsize_t returns negative value or fails with exception. Then attempt to clearself->items[i].literal intemplate_clear leads to dereferencing of uninitialized pointer.
Not sure if this worth fixing, since_sre.template is an internal implementation detail that is used only in_compile_template function, where it accepts only (I guess) correct templates created in_parser.parse_template function, and additional checks/initialization can affect its performance. But I'll submit a PR anyway.