Mercurial > cpython-lru_cache-weakref
diff Modules/parsermodule.c @ 37092:8d42f661fec8 legacy-trunk
SF #1445431, fix some leaks in error conditions.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 20 Mar 2006 04:08:12 +0000 |
| parents | 57322cb2ca11 |
| children | 6e1a899cac8e |
line wrap: on
line diff
--- a/Modules/parsermodule.c Mon Mar 20 02:04:23 2006 +0000 +++ b/Modules/parsermodule.c Mon Mar 20 04:08:12 2006 +0000 @@ -657,9 +657,10 @@ } } if (!ok) { - PyErr_SetObject(parser_error, - Py_BuildValue("os", elem, - "Illegal node construct.")); + PyObject *err = Py_BuildValue("os", elem, + "Illegal node construct."); + PyErr_SetObject(parser_error, err); + Py_XDECREF(err); Py_XDECREF(elem); return (0); } @@ -710,8 +711,9 @@ * It has to be one or the other; this is an error. * Throw an exception. */ - PyErr_SetObject(parser_error, - Py_BuildValue("os", elem, "unknown node type.")); + PyObject *err = Py_BuildValue("os", elem, "unknown node type."); + PyErr_SetObject(parser_error, err); + Py_XDECREF(err); Py_XDECREF(elem); return (0); } @@ -762,6 +764,7 @@ tuple = Py_BuildValue("os", tuple, "Illegal syntax-tree; cannot start with terminal symbol."); PyErr_SetObject(parser_error, tuple); + Py_XDECREF(tuple); } else if (ISNONTERMINAL(num)) { /* @@ -792,14 +795,16 @@ } } } - else + else { /* The tuple is illegal -- if the number is neither TERMINAL nor * NONTERMINAL, we can't use it. Not sure the implementation * allows this condition, but the API doesn't preclude it. */ - PyErr_SetObject(parser_error, - Py_BuildValue("os", tuple, - "Illegal component tuple.")); + PyObject *err = Py_BuildValue("os", tuple, + "Illegal component tuple."); + PyErr_SetObject(parser_error, err); + Py_XDECREF(err); + } return (res); }
