Fixed uninitialized return value in spdylay_session_new()

This commit is contained in:
Tatsuhiro Tsujikawa 2012-02-25 01:41:02 +09:00
parent 847830f132
commit 895562a15b
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,7 @@ static int spdylay_session_new(spdylay_session **session_ptr,
int r; int r;
*session_ptr = malloc(sizeof(spdylay_session)); *session_ptr = malloc(sizeof(spdylay_session));
if(*session_ptr == NULL) { if(*session_ptr == NULL) {
r = SPDYLAY_ERR_NOMEM;
goto fail_session; goto fail_session;
} }
memset(*session_ptr, 0, sizeof(spdylay_session)); memset(*session_ptr, 0, sizeof(spdylay_session));
@ -118,12 +119,14 @@ static int spdylay_session_new(spdylay_session **session_ptr,
(*session_ptr)->aob.framebuf = malloc (*session_ptr)->aob.framebuf = malloc
(SPDYLAY_INITIAL_OUTBOUND_FRAMEBUF_LENGTH); (SPDYLAY_INITIAL_OUTBOUND_FRAMEBUF_LENGTH);
if((*session_ptr)->aob.framebuf == NULL) { if((*session_ptr)->aob.framebuf == NULL) {
r = SPDYLAY_ERR_NOMEM;
goto fail_aob_framebuf; goto fail_aob_framebuf;
} }
(*session_ptr)->aob.framebufmax = SPDYLAY_INITIAL_OUTBOUND_FRAMEBUF_LENGTH; (*session_ptr)->aob.framebufmax = SPDYLAY_INITIAL_OUTBOUND_FRAMEBUF_LENGTH;
(*session_ptr)->nvbuf = malloc(SPDYLAY_INITIAL_NV_BUFFER_LENGTH); (*session_ptr)->nvbuf = malloc(SPDYLAY_INITIAL_NV_BUFFER_LENGTH);
if((*session_ptr)->nvbuf == NULL) { if((*session_ptr)->nvbuf == NULL) {
r = SPDYLAY_ERR_NOMEM;
goto fail_nvbuf; goto fail_nvbuf;
} }
(*session_ptr)->nvbuflen = SPDYLAY_INITIAL_NV_BUFFER_LENGTH; (*session_ptr)->nvbuflen = SPDYLAY_INITIAL_NV_BUFFER_LENGTH;
@ -143,6 +146,7 @@ static int spdylay_session_new(spdylay_session **session_ptr,
(*session_ptr)->iframe.state = SPDYLAY_RECV_HEAD; (*session_ptr)->iframe.state = SPDYLAY_RECV_HEAD;
(*session_ptr)->iframe.buf = malloc(SPDYLAY_INITIAL_INBOUND_FRAMEBUF_LENGTH); (*session_ptr)->iframe.buf = malloc(SPDYLAY_INITIAL_INBOUND_FRAMEBUF_LENGTH);
if((*session_ptr)->iframe.buf == NULL) { if((*session_ptr)->iframe.buf == NULL) {
r = SPDYLAY_ERR_NOMEM;
goto fail_iframe_buf; goto fail_iframe_buf;
} }
(*session_ptr)->iframe.bufmax = SPDYLAY_INITIAL_INBOUND_FRAMEBUF_LENGTH; (*session_ptr)->iframe.bufmax = SPDYLAY_INITIAL_INBOUND_FRAMEBUF_LENGTH;