summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libproxy/url.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libproxy/url.cpp b/libproxy/url.cpp
index 8d9de0c..a4895d4 100644
--- a/libproxy/url.cpp
+++ b/libproxy/url.cpp
@@ -460,7 +460,7 @@ char* url::get_pac() {
// Get content
unsigned int recvd = 0;
buffer = new char[PAC_MAX_SIZE];
- *buffer = '\0';
+ memset(buffer, 0, PAC_MAX_SIZE);
do {
unsigned int chunk_length;
@@ -480,14 +480,13 @@ char* url::get_pac() {
while (recvd != content_length) {
int r = recv(sock, buffer + recvd, content_length - recvd, 0);
- if (r < 0) {
- recvd = content_length;
+ if (r <= 0) {
+ chunked = false;
break;
}
recvd += r;
}
- buffer[content_length] = '\0';
- } while (recvd != content_length);
+ } while (chunked);
if (string(buffer).size() != content_length) {
delete[] buffer;