Commit 30282623 authored by Barry Warsaw's avatar Barry Warsaw

EnvironmentError__init__(): The two case clauses were missing

`break's.  This first missing break caused a memory leak when case 3
fell through case 2 in the following example:

import os
os.chmod('/missing', 0600)
parent 8e823053
...@@ -440,8 +440,10 @@ EnvironmentError__init__(PyObject* self, PyObject* args) ...@@ -440,8 +440,10 @@ EnvironmentError__init__(PyObject* self, PyObject* args)
switch (PySequence_Length(args)) { switch (PySequence_Length(args)) {
case 3: case 3:
/* open() errors give third argument which is the filename. But so /* Where a function has a single filename, such as open() or some
* common in-place unpacking doesn't break, e.g.: * of the os module functions, PyErr_SetFromErrnoWithFilename() is
* called, giving a third argument which is the filename. But, so
* that old code using in-place unpacking doesn't break, e.g.:
* *
* except IOError, (errno, strerror): * except IOError, (errno, strerror):
* *
...@@ -465,9 +467,12 @@ EnvironmentError__init__(PyObject* self, PyObject* args) ...@@ -465,9 +467,12 @@ EnvironmentError__init__(PyObject* self, PyObject* args)
subslice = PySequence_GetSlice(args, 0, 2); subslice = PySequence_GetSlice(args, 0, 2);
if (!subslice || PyObject_SetAttrString(self, "args", subslice)) if (!subslice || PyObject_SetAttrString(self, "args", subslice))
goto finally; goto finally;
break;
case 2: case 2:
/* common case: PyErr_SetFromErrno() */ /* Used when PyErr_SetFromErrno() is called and no filename
* argument is given.
*/
item0 = PySequence_GetItem(args, 0); item0 = PySequence_GetItem(args, 0);
item1 = PySequence_GetItem(args, 1); item1 = PySequence_GetItem(args, 1);
if (!item0 || !item1) if (!item0 || !item1)
...@@ -478,6 +483,7 @@ EnvironmentError__init__(PyObject* self, PyObject* args) ...@@ -478,6 +483,7 @@ EnvironmentError__init__(PyObject* self, PyObject* args)
{ {
goto finally; goto finally;
} }
break;
} }
Py_INCREF(Py_None); Py_INCREF(Py_None);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment