self.assertEqual(pattern.sub('#', 'a\nb\nc'), 'a#\nb#\nc#')
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
Library
-------
+- Issue #3299: Fix possible crash in the _sre module when given bad
+ argument values in debug mode. Patch by Victor Stinner.
+
- Issue #5827: Make sure that normpath preserves unicode. Initial patch
by Matt Giuca.
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;
}
if (PyErr_Occurred()) {
- PyObject_DEL(self);
+ Py_DECREF(self);
return NULL;
}
scanner_dealloc(ScannerObject* self)
{
state_fini(&self->state);
- Py_DECREF(self->pattern);
+ Py_XDECREF(self->pattern);
PyObject_DEL(self);
}
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;
}