From e04e24c1c27516a32293c7e67cc2a80e2125c095 Mon Sep 17 00:00:00 2001 From: Mike Conlen Date: Thu, 21 Apr 2016 22:53:19 +0000 Subject: [PATCH] in nghttp2_session_send() data is declared uninitialized and used after a call to nghttp2_session_mem_send_internal() which should set it, however in nghttp2_session_mem_send_internal() it is possible to return before setting the pointer. This change initializes the variable to NULL where delcared and sets the variable in nghttp2_session_mem_send_internal() to NULL before possibly returning rather than after. both options are not necessary but are both ideal practice --- lib/nghttp2_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 2c927bb6..5a300445 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -2877,6 +2877,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, aob = &session->aob; framebufs = &aob->framebufs; + *data_ptr = NULL; /* We may have idle streams more than we expect (e.g., nghttp2_session_change_stream_priority() or nghttp2_session_create_idle_stream()). Adjust them here. */ @@ -2885,7 +2886,6 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session, return rv; } - *data_ptr = NULL; for (;;) { switch (aob->state) { case NGHTTP2_OB_POP_ITEM: { @@ -3163,7 +3163,7 @@ ssize_t nghttp2_session_mem_send(nghttp2_session *session, } int nghttp2_session_send(nghttp2_session *session) { - const uint8_t *data; + const uint8_t *data = NULL; ssize_t datalen; ssize_t sentlen; nghttp2_bufs *framebufs;