New submission from STINNER Victor <victor.stin...@haypocalc.com>:

getstring() of the _sre module contains the following code:
-------------
    ...
    buffer = Py_TYPE(string)->tp_as_buffer;
    if (!buffer || !buffer->bf_getbuffer ||
        (*buffer->bf_getbuffer)(string, &view, PyBUF_SIMPLE) < 0) {
            PyErr_SetString(PyExc_TypeError, "expected string or buffer");
            return NULL;
    }

    /* determine buffer size */
    bytes = view.len;
    ptr = view.buf;

    /* Release the buffer immediately --- possibly dangerous
       but doing something else would require some re-factoring
    */
    PyBuffer_Release(&view);
    ...
-------------

getstring() is used to initialize a state or a pattern. State and pattern have 
destructors (pattern_dealloc() and state_fini()), so it should be possible to 
keep the view active and call PyBuffer_Release() in the destructor.

----------
components: Library (Lib)
messages: 144714
nosy: haypo, pitrou
priority: normal
severity: normal
status: open
title: _sre: getstring() releases the buffer before using it
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13083>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to