summaryrefslogtreecommitdiff
path: root/Modules/_io/clinic/bytesio.c.h
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
commitb2fa705fd3887c326e811c418469c784353027f4 (patch)
treeb3428f73de91453edbfd4df1a5d4a212d182eb44 /Modules/_io/clinic/bytesio.c.h
parent134e58fd3aaa2e91390041e143f3f0a21a60142b (diff)
parentb53654b6dbfce8318a7d4d1cdaddca7a7fec194b (diff)
downloadcpython-b2fa705fd3887c326e811c418469c784353027f4.tar.gz
Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
Diffstat (limited to 'Modules/_io/clinic/bytesio.c.h')
-rw-r--r--Modules/_io/clinic/bytesio.c.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 5f2abb03a7..c64ce5c77c 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -171,8 +171,9 @@ _io_BytesIO_read(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_read_impl(self, arg);
exit:
@@ -215,8 +216,9 @@ _io_BytesIO_readline(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readline_impl(self, arg);
exit:
@@ -247,8 +249,9 @@ _io_BytesIO_readlines(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "readlines",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readlines_impl(self, arg);
exit:
@@ -276,14 +279,16 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io_BytesIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -311,8 +316,9 @@ _io_BytesIO_truncate(bytesio *self, PyObject *args)
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_truncate_impl(self, arg);
exit:
@@ -345,8 +351,9 @@ _io_BytesIO_seek(bytesio *self, PyObject *args)
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
@@ -408,15 +415,17 @@ static int
_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"initial_bytes", NULL};
+ static const char * const _keywords[] = {"initial_bytes", NULL};
+ static _PyArg_Parser _parser = {"|O:BytesIO", _keywords, 0};
PyObject *initvalue = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords,
- &initvalue))
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
+ &initvalue)) {
goto exit;
+ }
return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
exit:
return return_value;
}
-/*[clinic end generated code: output=60ce2c6272718431 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6382e8eb578eea64 input=a9049054013a1b77]*/