Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

_sre.template crashes in case of negative or non-integer group index #106524

Closed
Labels
topic-regextype-crashA hard crash of the interpreter, possibly with a core dump
@chgnrdv

Description

@chgnrdv

_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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-regextype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp