diff options
author | Yang Tse <yangsita@gmail.com> | 2011-09-05 23:45:04 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-09-05 23:45:04 +0200 |
commit | e9e894905c5743d24f318b5a3d33802caa136f5f (patch) | |
tree | 1b4de2274d06f040953db6801f0b087ec86332fb /lib/pingpong.c | |
parent | a50210710ab6fd772e2762ed36602c15adfb49e1 (diff) | |
download | curl-e9e894905c5743d24f318b5a3d33802caa136f5f.tar.gz |
pingpong.c: avoid a memmove call in function Curl_pp_vsendf
Diffstat (limited to 'lib/pingpong.c')
-rw-r--r-- | lib/pingpong.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/pingpong.c b/lib/pingpong.c index da1391e8e..84ce88148 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -195,6 +195,10 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, enum protection_level data_sec = conn->data_prot; #endif + DEBUGASSERT(pp->sendleft == 0); + DEBUGASSERT(pp->sendsize == 0); + DEBUGASSERT(pp->sendthis == NULL); + fmt_crlf = aprintf("%s\r\n", fmt); /* append a trailing CRLF */ if(!fmt_crlf) return CURLE_OUT_OF_MEMORY; @@ -236,11 +240,10 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, s, (size_t)bytes_written, conn); if(bytes_written != (ssize_t)write_len) { - /* the whole chunk was not sent, store the rest of the data */ - write_len -= bytes_written; - memmove(s, s + bytes_written, write_len + 1); + /* the whole chunk was not sent, keep it around and adjust sizes */ pp->sendthis = s; - pp->sendsize = pp->sendleft = write_len; + pp->sendsize = write_len; + pp->sendleft = write_len - bytes_written; } else { free(s); |