summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2016-01-06 22:10:49 -0500
committerJay Satiro <raysatiro@yahoo.com>2016-01-06 22:10:49 -0500
commit973ee6bdd3d444b94d431c3c31f5848d3f06ed75 (patch)
tree45c26a4c6bc577ecee79dc9615c18c2e70ee13f4
parent3de2d48d4ce195e29492fce23f76b7055f2a1511 (diff)
downloadcurl-973ee6bdd3d444b94d431c3c31f5848d3f06ed75.tar.gz
http2: Fix client write for trailers on stream close
Check that the trailer buffer exists before attempting a client write for trailers on stream close. Refer to comments in https://github.com/bagder/curl/pull/564
-rw-r--r--lib/http2.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/http2.c b/lib/http2.c
index eb54d89b0..ba55877a5 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -1043,21 +1043,23 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
return -1;
}
- trailer_pos = stream->trailer_recvbuf->buffer;
- trailer_end = trailer_pos + stream->trailer_recvbuf->size_used;
+ if(stream->trailer_recvbuf && stream->trailer_recvbuf->buffer) {
+ trailer_pos = stream->trailer_recvbuf->buffer;
+ trailer_end = trailer_pos + stream->trailer_recvbuf->size_used;
- for(; trailer_pos < trailer_end;) {
- uint32_t n;
- memcpy(&n, trailer_pos, sizeof(n));
- trailer_pos += sizeof(n);
+ for(; trailer_pos < trailer_end;) {
+ uint32_t n;
+ memcpy(&n, trailer_pos, sizeof(n));
+ trailer_pos += sizeof(n);
- result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailer_pos, n);
- if(result) {
- *err = result;
- return -1;
- }
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailer_pos, n);
+ if(result) {
+ *err = result;
+ return -1;
+ }
- trailer_pos += n + 1;
+ trailer_pos += n + 1;
+ }
}
DEBUGF(infof(data, "http2_recv returns 0, http2_handle_stream_close\n"));