From a93ff5bf1f82d24d99cf99680d5c5819a2497ab7 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Tue, 8 May 2012 19:14:25 +0200 Subject: [PATCH] allows multiple start_response without leaks --- plugins/python/wsgi_headers.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/python/wsgi_headers.c b/plugins/python/wsgi_headers.c index dd803b35..886a18e3 100644 --- a/plugins/python/wsgi_headers.c +++ b/plugins/python/wsgi_headers.c @@ -24,6 +24,12 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) { return PyErr_Format(PyExc_IOError, "headers already sent"); } + // decref old status line + if (wsgi_req->status_header) { + Py_DECREF((PyObject *)wsgi_req->status_header); + wsgi_req->status_header = NULL; + } + // this must be done before headers management if (PyTuple_Size(args) > 2) { exc_info = PyTuple_GetItem(args, 2); @@ -262,7 +268,11 @@ int uwsgi_python_do_send_headers(struct wsgi_request *wsgi_req) { wsgi_req->headers_sent = 1; - Py_DECREF((PyObject *)wsgi_req->status_header); + // decref status line + if (wsgi_req->status_header) { + Py_DECREF((PyObject *)wsgi_req->status_header); + wsgi_req->status_header = NULL; + } if (wsgi_req->write_errors > uwsgi.write_errors_tolerance && !uwsgi.disable_write_exception) { uwsgi_py_write_set_exception(wsgi_req);