diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-14 17:25:24 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-14 17:25:24 (GMT) |
commit | efdddd3370fc646836b6113247159846734fc129 (patch) | |
tree | e6756e2bf9607e658ba334ab90ff0e6771500986 /Modules | |
parent | fd3a60d5efb7ad1e2127d66d151c2cc4280b112b (diff) | |
download | cpython-efdddd3370fc646836b6113247159846734fc129.zip cpython-efdddd3370fc646836b6113247159846734fc129.tar.gz cpython-efdddd3370fc646836b6113247159846734fc129.tar.bz2 |
Issue #3299: Fix possible crash in the _sre module when given bad
argument values in debug mode. Patch by Victor Stinner.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sre.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index 0d9ee24..2cf9705 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -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()) { - PyObject_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_XDECREF(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) { - PyObject_DEL(self); + Py_DECREF(self); return NULL; } |