From 1a1ab2e2e8abb6618721188109156e5bdda35cdd Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 21 Oct 2005 21:00:44 +0000
Subject: [PATCH] "Ofer" reported a problem when libcurl re-used a connection
 and failed to do it, it could then accidentally actually crash. Presumably,
 this concerns FTP connections.  http://curl.haxx.se/bug/view.cgi?id=1330310

---
 CHANGES   | 4 ++++
 lib/url.c | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index 452e46bd66..0fd2fe2a52 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,10 @@
 
 
 Daniel (21 October 2005)
+- "Ofer" reported a problem when libcurl re-used a connection and failed to do
+  it, it could then accidentally actually crash. Presumably, this concerns FTP
+  connections.  http://curl.haxx.se/bug/view.cgi?id=1330310
+
 - Temprimus improved the MSVC makefile so that the static debug SSL libs are
   linked to the executable and not to the libcurld.lib
   http://curl.haxx.se/bug/view.cgi?id=1326676
diff --git a/lib/url.c b/lib/url.c
index 3f11b3e751..c4f3fbf3d4 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3844,7 +3844,14 @@ CURLcode Curl_do(struct connectdata **connp, bool *done)
 
       /* conn may no longer be a good pointer */
 
-      if(CURLE_OK == result) {
+      /*
+       * According to bug report #1330310. We need to check for
+       * CURLE_SEND_ERROR here as well. I figure this could happen when the
+       * request failed on a FTP connection and thus Curl_done() itself tried
+       * to use the connection (again). Slight Lack of feedback in the report,
+       * but I don't think this extra check can do much harm.
+       */
+      if((CURLE_OK == result) || (CURLE_SEND_ERROR == result)) {
         bool async;
         bool protocol_done = TRUE;
 
-- 
GitLab