aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-03-31 10:00:55 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-03-31 10:10:58 +0200
commitb22a9547364a5aa0b939feb8e29fd072f615272f (patch)
tree5307643bb8815fb4273725546e21d3709f844122 /lib/http.c
parentb3912d9dd730b468fd7862e5f47e569dd9976f11 (diff)
Curl_add_buffer_send: avoid possible NULL dereference
... as we check for a NULL pointer below, we move the derefence to after the check. Detected by PVS Studio. Reported-by: Alexis La Goutte
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/http.c b/lib/http.c
index 22ef44731..73d662569 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1133,10 +1133,6 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
ptr+headlen, bodylen, conn);
}
}
- if(bodylen)
- /* since we sent a piece of the body here, up the byte counter for it
- accordingly */
- http->writebytecount += bodylen;
/* 'amount' can never be a very large value here so typecasting it so a
signed 31 bit value should not cause problems even if ssize_t is
@@ -1144,6 +1140,10 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
*bytes_written += (long)amount;
if(http) {
+ /* if we sent a piece of the body here, up the byte counter for it
+ accordingly */
+ http->writebytecount += bodylen;
+
if((size_t)amount != size) {
/* The whole request could not be sent in one system call. We must
queue it up and send it later when we get the chance. We must not