This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Argument Clinic: Py_buffer parameters are not initialized
Type: crash Stage: resolved
Components: Build Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: larry Nosy List: larry, python-dev, serhiy.storchaka
Priority: release blocker Keywords:

Created on 2014-01-06 14:05 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
spammodule.c serhiy.storchaka, 2014-01-06 14:05 An example
larry.clinic.py_buffer.initialization.patch.1.txt larry, 2014-01-06 17:12 review
Messages (5)
msg207433 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-06 14:05
Argument Clinic doesn't initialize Py_buffer parameters. It generates cleanup code:

    /* Cleanup for data */
    if (data.buf)
       PyBuffer_Release(&data);

And if PyArg_ParseTuple() is failed, the buf attribute can contains arbitrary (non-NULL) data. This causes crash in PyBuffer_Release(). See issue20133 for working example.
msg207456 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-06 17:12
Here's a patch, please review.  You can see how Py_buffer variables are initialized in zlibmodule.c in the patch.
msg207460 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-06 18:18
LGTM.

But is not {NULL} enough for Py_buffer initialization?
msg207461 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-06 18:20
Or perhaps we should introduce macros Py_buffer_INIT.
msg207466 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-01-06 18:34
New changeset 16ff19d1d367 by Larry Hastings in branch 'default':
Issue #20142: Py_buffer variables generated by Argument Clinic are now
http://hg.python.org/cpython/rev/16ff19d1d367
History
Date User Action Args
2022-04-11 14:57:56adminsetgithub: 64341
2014-01-06 18:35:06larrysetstatus: open -> closed
assignee: larry
resolution: fixed
stage: resolved
2014-01-06 18:34:33python-devsetnosy: + python-dev
messages: + msg207466
2014-01-06 18:20:48serhiy.storchakasetmessages: + msg207461
2014-01-06 18:18:55serhiy.storchakasetmessages: + msg207460
2014-01-06 17:12:59larrysetfiles: + larry.clinic.py_buffer.initialization.patch.1.txt

messages: + msg207456
2014-01-06 17:07:58serhiy.storchakalinkissue20133 dependencies
2014-01-06 14:05:53serhiy.storchakacreate