From 07bd3f5df04093b3b2f75b69514bc22d61066619 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 3 Mar 2013 19:06:59 +0100 Subject: [PATCH] core/exception: avoid null pointer dereference in uwsgi_exception_run_handlers If wsgi_req is NULL and uwsgi.reload_on_exception is True Reported by Coverity as CID #989244. --- core/exceptions.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/exceptions.c b/core/exceptions.c index fe7e69f6..b67ba8df 100644 --- a/core/exceptions.c +++ b/core/exceptions.c @@ -316,12 +316,11 @@ static void uwsgi_exception_run_handlers(struct uwsgi_buffer *ub) { void uwsgi_manage_exception(struct wsgi_request *wsgi_req,int catch) { - int do_exit = 0; + int do_exit = uwsgi.reload_on_exception; - if (uwsgi.reload_on_exception) { - do_exit = 1; - goto check_catch; - } + if (!wsgi_req) goto log2; + + if (do_exit) goto check_catch; if (wsgi_req && uwsgi.exception_handlers_instance) { struct uwsgi_buffer *ehi = uwsgi_exception_handler_object(wsgi_req); @@ -331,8 +330,6 @@ void uwsgi_manage_exception(struct wsgi_request *wsgi_req,int catch) { } } - if (!wsgi_req) goto log2; - uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].exceptions++; uwsgi_apps[wsgi_req->app_id].exceptions++;