add_buffer_send() free()d the buffer *before* it was used! :-O
authorDaniel Stenberg <daniel@haxx.se>
Tue, 3 Oct 2000 16:53:41 +0000 (16:53 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 3 Oct 2000 16:53:41 +0000 (16:53 +0000)
lib/sendf.c

index 8042ac8b9ed26d56963d33841e836e4fe87cddc2..723acc481fdd179d7ee39579969ee0c0ef99f686 100644 (file)
@@ -194,17 +194,20 @@ send_buffer *add_buffer_init(void)
  */
 size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
 {
-  if(in->buffer)
-    free(in->buffer);
-  free(in);
-
+  size_t amount;
   if(conn->data->bits.verbose) {
     fputs("> ", conn->data->err);
     /* this data _may_ contain binary stuff */
     fwrite(in->buffer, in->size_used, 1, conn->data->err);
   }
 
-  return ssend(sockfd, conn, in->buffer, in->size_used);
+  amount = ssend(sockfd, conn, in->buffer, in->size_used);
+
+  if(in->buffer)
+    free(in->buffer);
+  free(in);
+
+  return amount;
 }