diff options
author | Barry Warsaw <barry@python.org> | 2000-07-09 04:56:25 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-07-09 04:56:25 (GMT) |
commit | 7dfeb42939b36919d59943360e737389e1202c47 (patch) | |
tree | 747fb944597a7c89a7c1ff798d94d58764aff0b2 /Python | |
parent | 4288c80599642880dd5710ccd2ce5d2c80696a81 (diff) | |
download | cpython-7dfeb42939b36919d59943360e737389e1202c47.zip cpython-7dfeb42939b36919d59943360e737389e1202c47.tar.gz cpython-7dfeb42939b36919d59943360e737389e1202c47.tar.bz2 |
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)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/exceptions.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/exceptions.c b/Python/exceptions.c index 2726519..c32e15c 100644 --- a/Python/exceptions.c +++ b/Python/exceptions.c @@ -440,8 +440,10 @@ EnvironmentError__init__(PyObject* self, PyObject* args) switch (PySequence_Length(args)) { case 3: - /* open() errors give third argument which is the filename. But so - * common in-place unpacking doesn't break, e.g.: + /* Where a function has a single filename, such as open() or some + * 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): * @@ -465,9 +467,12 @@ EnvironmentError__init__(PyObject* self, PyObject* args) subslice = PySequence_GetSlice(args, 0, 2); if (!subslice || PyObject_SetAttrString(self, "args", subslice)) goto finally; + break; case 2: - /* common case: PyErr_SetFromErrno() */ + /* Used when PyErr_SetFromErrno() is called and no filename + * argument is given. + */ item0 = PySequence_GetItem(args, 0); item1 = PySequence_GetItem(args, 1); if (!item0 || !item1) @@ -478,6 +483,7 @@ EnvironmentError__init__(PyObject* self, PyObject* args) { goto finally; } + break; } Py_INCREF(Py_None); |