]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-98740: Fix validation of conditional expressions in RE (GH-98764)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 3 Nov 2022 07:23:46 +0000 (09:23 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Nov 2022 07:23:46 +0000 (09:23 +0200)
commite9ac890c0273aee413aa528cc202c3efa29f1d7a
treee9dc563c58e25de5dd3f5b592fa5575ea486349d
parent41bc101dd6726edc5fbd4a934ea057ec712d5498
gh-98740: Fix validation of conditional expressions in RE (GH-98764)

In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.

NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c.  Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
Doc/library/re.rst
Lib/test/test_re.py
Misc/NEWS.d/next/Library/2022-10-27-12-56-38.gh-issue-98740.ZoqqGM.rst [new file with mode: 0644]
Modules/_sre/sre.c