From bf1be4850e4a4b4053f28c35f40815f25ca7d401 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 29 Jan 2012 19:15:59 +0900 Subject: [PATCH] spdylay_submit_request: Fixed segmentation fault if data_prd is NULL --- lib/spdylay_session.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/spdylay_session.c b/lib/spdylay_session.c index c16b0c11..1f2cfa1e 100644 --- a/lib/spdylay_session.c +++ b/lib/spdylay_session.c @@ -1303,15 +1303,17 @@ int spdylay_submit_request(spdylay_session *session, uint8_t pri, spdylay_frame *frame; char **nv_copy; uint8_t flags = 0; - spdylay_data_provider *data_prd_copy; + spdylay_data_provider *data_prd_copy = NULL; if(pri > 3) { return SPDYLAY_ERR_INVALID_ARGUMENT; } - data_prd_copy = malloc(sizeof(spdylay_data_provider)); - if(data_prd_copy == NULL) { - return SPDYLAY_ERR_NOMEM; + if(data_prd) { + data_prd_copy = malloc(sizeof(spdylay_data_provider)); + if(data_prd_copy == NULL) { + return SPDYLAY_ERR_NOMEM; + } + *data_prd_copy = *data_prd; } - *data_prd_copy = *data_prd; frame = malloc(sizeof(spdylay_frame)); if(frame == NULL) { free(data_prd_copy);