Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
efdddd33
Commit
efdddd33
authored
Jan 14, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #3299: Fix possible crash in the _sre module when given bad
argument values in debug mode. Patch by Victor Stinner.
parent
fd3a60d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
Lib/test/test_re.py
Lib/test/test_re.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_sre.c
Modules/_sre.c
+8
-3
No files found.
Lib/test/test_re.py
View file @
efdddd33
...
...
@@ -703,6 +703,12 @@ class ReTests(unittest.TestCase):
self.assertEqual(pattern.sub('#', 'a
\
n
b
\
n
c'), 'a#
\
n
b#
\
n
c#')
self.assertEqual(pattern.sub('#', '
\
n
'), '#
\
n
#')
def test_dealloc(self):
# issue 3299: check for segfault in debug build
import _sre
long_overflow = sys.maxsize + 2
self.assertRaises(TypeError, re.finditer, "
a
", {})
self.assertRaises(OverflowError, _sre.compile, "
abc
", 0, [long_overflow])
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
...
...
Misc/NEWS
View file @
efdddd33
...
...
@@ -32,6 +32,9 @@ Core and Builtins
Library
-------
- Issue #3299: Fix possible crash in the _sre module when given bad
argument values in debug mode. Patch by Victor Stinner.
- Issue #7703: Add support for the new buffer API to functions of the
binascii module. Backported from py3k by Florent Xicluna, with some
additional tests.
...
...
Modules/_sre.c
View file @
efdddd33
...
...
@@ -2684,6 +2684,10 @@ _compile(PyObject* self_, PyObject* args)
self
=
PyObject_NEW_VAR
(
PatternObject
,
&
Pattern_Type
,
n
);
if
(
!
self
)
return
NULL
;
self
->
weakreflist
=
NULL
;
self
->
pattern
=
NULL
;
self
->
groupindex
=
NULL
;
self
->
indexgroup
=
NULL
;
self
->
codesize
=
n
;
...
...
@@ -2700,7 +2704,7 @@ _compile(PyObject* self_, PyObject* args)
}
if
(
PyErr_Occurred
())
{
Py
Object_DEL
(
self
);
Py
_DECREF
(
self
);
return
NULL
;
}
...
...
@@ -3718,7 +3722,7 @@ static void
scanner_dealloc
(
ScannerObject
*
self
)
{
state_fini
(
&
self
->
state
);
Py_DECREF
(
self
->
pattern
);
Py_
X
DECREF
(
self
->
pattern
);
PyObject_DEL
(
self
);
}
...
...
@@ -3840,10 +3844,11 @@ pattern_scanner(PatternObject* pattern, PyObject* args)
self
=
PyObject_NEW
(
ScannerObject
,
&
Scanner_Type
);
if
(
!
self
)
return
NULL
;
self
->
pattern
=
NULL
;
string
=
state_init
(
&
self
->
state
,
pattern
,
string
,
start
,
end
);
if
(
!
string
)
{
Py
Object_DEL
(
self
);
Py
_DECREF
(
self
);
return
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment