Index: http.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http.c,v
retrieving revision 1.346
diff -u -r1.346 http.c
--- http.c	14 Nov 2007 00:48:14 -0000	1.346
+++ http.c	15 Nov 2007 13:38:12 -0000
@@ -937,23 +937,25 @@
 
   sockfd = conn->sock[socketindex];
 
-  /* The looping below is required since we use non-blocking sockets, but due
-     to the circumstances we will just loop and try again and again etc */
-
   ptr = in->buffer;
   size = in->size_used;
 
+  if(included_body_bytes >= size) {
+    if(in->buffer)
+      free(in->buffer);
+    free(in);
+    return CURLE_SEND_ERROR;
+  }
+
 #ifdef CURL_DOES_CONVERSIONS
-  if(size - included_body_bytes > 0) {
-    res = Curl_convert_to_network(conn->data, ptr, size - included_body_bytes);
-    /* Curl_convert_to_network calls failf if unsuccessful */
-    if(res != CURLE_OK) {
-      /* conversion failed, free memory and return to the caller */
-      if(in->buffer)
-        free(in->buffer);
-      free(in);
-      return res;
-    }
+  res = Curl_convert_to_network(conn->data, ptr, size - included_body_bytes);
+  /* Curl_convert_to_network calls failf if unsuccessful */
+  if(res != CURLE_OK) {
+    /* conversion failed, free memory and return to the caller */
+    if(in->buffer)
+      free(in->buffer);
+    free(in);
+    return res;
   }
 #endif /* CURL_DOES_CONVERSIONS */
 
