curl/multi-avoid-double-free.patch

69 lines
2.3 KiB
Diff
Raw Normal View History

2019-09-30 10:36:29 -04:00
From 42c2b14aefb9bd580fe5128147bf52840e61c292 Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Mon, 18 Mar 2019 17:22:21 -0400
Subject: [PATCH] 0191
---
lib/multi.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/multi.c b/lib/multi.c
index 8e920fc..3b85fee 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1707,7 +1707,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
char *newurl = NULL;
followtype follow = FOLLOW_NONE;
CURLcode drc;
- bool retry = FALSE;
drc = Curl_retry_request(data->easy_conn, &newurl);
if(drc) {
@@ -1715,15 +1714,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = drc;
stream_error = TRUE;
}
- else
- retry = (newurl)?TRUE:FALSE;
Curl_posttransfer(data);
drc = multi_done(&data->easy_conn, result, FALSE);
/* When set to retry the connection, we must to go back to
* the CONNECT state */
- if(retry) {
+ if(newurl) {
if(!drc || (drc == CURLE_SEND_ERROR)) {
follow = FOLLOW_RETRY;
drc = Curl_follow(data, newurl, follow);
@@ -1986,16 +1983,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else
follow = FOLLOW_RETRY;
result = multi_done(&data->easy_conn, CURLE_OK, FALSE);
- if(result)
- /* Curl_follow() would otherwise free this */
- free(newurl);
- else {
+ if(!result) {
result = Curl_follow(data, newurl, follow);
if(!result) {
multistate(data, CURLM_STATE_CONNECT);
rc = CURLM_CALL_MULTI_PERFORM;
}
}
+ free(newurl);
}
else {
/* after the transfer is done, go DONE */
@@ -2007,6 +2002,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
newurl = data->req.location;
data->req.location = NULL;
result = Curl_follow(data, newurl, FOLLOW_FAKE);
+ free(newurl);
if(result) {
stream_error = TRUE;
result = multi_done(&data->easy_conn, result, TRUE);
--
1.8.3.1