libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit d5993f6c1f323d0de2577a82143cdc9f6c3facc1
parent 62ac46dec6240a0739505635383e5c812001c879
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 31 Oct 2021 17:50:48 +0300

MHD_queue_response(): restored behavior with wrong parameters

Do not crash with NULL connection pointer (as before).

Diffstat:
Msrc/microhttpd/connection.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -4934,11 +4934,10 @@ MHD_queue_response (struct MHD_Connection *connection, { struct MHD_Daemon *daemon; - daemon = connection->daemon; + if ((NULL == connection) || (NULL == response)) + return MHD_NO; - if (daemon->shutdown) - return MHD_YES; /* If daemon was shut down in parallel, - * response will be aborted now or on later stage. */ + daemon = connection->daemon; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if ( (! connection->suspended) && @@ -4953,9 +4952,11 @@ MHD_queue_response (struct MHD_Connection *connection, } #endif - if ( (NULL == connection) || - (NULL == response) || - (NULL != connection->response) || + if (daemon->shutdown) + return MHD_YES; /* If daemon was shut down in parallel, + * response will be aborted now or on later stage. */ + + if ( (NULL != connection->response) || ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && (MHD_CONNECTION_FULL_REQ_RECEIVED != connection->state) ) ) return MHD_NO;