summaryrefslogtreecommitdiff
path: root/lib/rtsp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-11-10 08:38:01 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-11-10 12:36:27 +0100
commitb25e4be79f8ff8ebd061672da6680a8ebb37350a (patch)
tree6ef7e1abc1a1e8cee23d61b214e42a0daf1a9e6f /lib/rtsp.c
parentf65f445f5482c00d532a3ecee1aba5effe1a2e4f (diff)
downloadcurl-b25e4be79f8ff8ebd061672da6680a8ebb37350a.tar.gz
rtsp: only store first_host once
Suggested-by: Erik Janssen URL: https://github.com/curl/curl/pull/9870#issuecomment-1309499744 Closes #9882
Diffstat (limited to 'lib/rtsp.c')
-rw-r--r--lib/rtsp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/rtsp.c b/lib/rtsp.c
index e32756fd8..b071458be 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -270,15 +270,14 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
/* Setup the first_* fields to allow auth details get sent
to this origin */
- /* Free to avoid leaking memory on multiple requests */
- free(data->state.first_host);
-
- data->state.first_host = strdup(conn->host.name);
- if(!data->state.first_host)
- return CURLE_OUT_OF_MEMORY;
+ if(!data->state.first_host) {
+ data->state.first_host = strdup(conn->host.name);
+ if(!data->state.first_host)
+ return CURLE_OUT_OF_MEMORY;
- data->state.first_remote_port = conn->remote_port;
- data->state.first_remote_protocol = conn->handler->protocol;
+ data->state.first_remote_port = conn->remote_port;
+ data->state.first_remote_protocol = conn->handler->protocol;
+ }
/* Setup the 'p_request' pointer to the proper p_request string
* Since all RTSP requests are included here, there is no need to