Skip to content

Commit a451c9e

Browse files
committed
Fix HTTPClient crash on GET() for url with redirects
Fixes: #4931
1 parent d362e1e commit a451c9e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

libraries/HTTPClient/src/HTTPClient.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ HTTPClient::~HTTPClient()
109109
if(_currentHeaders) {
110110
delete[] _currentHeaders;
111111
}
112+
if(_tcpDeprecated) {
113+
_tcpDeprecated.reset(nullptr);
114+
}
115+
if(_transportTraits) {
116+
_transportTraits.reset(nullptr);
117+
}
112118
}
113119

114120
void HTTPClient::clear()
@@ -284,7 +290,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
284290
}
285291
_host = the_host;
286292
_uri = url;
287-
log_d("host: %s port: %d url: %s", _host.c_str(), _port, _uri.c_str());
293+
log_d("protocol: %s, host: %s port: %d url: %s", _protocol.c_str(), _host.c_str(), _port, _uri.c_str());
288294
return true;
289295
}
290296

@@ -376,19 +382,19 @@ void HTTPClient::disconnect(bool preserveClient)
376382
}
377383

378384
if(_reuse && _canReuse) {
379-
log_d("tcp keep open for reuse\n");
385+
log_d("tcp keep open for reuse");
380386
} else {
381-
log_d("tcp stop\n");
387+
log_d("tcp stop");
382388
_client->stop();
383389
if(!preserveClient) {
384390
_client = nullptr;
385-
}
386391
#ifdef HTTPCLIENT_1_1_COMPATIBLE
387-
if(_tcpDeprecated) {
388-
_transportTraits.reset(nullptr);
389-
_tcpDeprecated.reset(nullptr);
390-
}
392+
if(_tcpDeprecated) {
393+
_transportTraits.reset(nullptr);
394+
_tcpDeprecated.reset(nullptr);
395+
}
391396
#endif
397+
}
392398
}
393399
} else {
394400
log_d("tcp is closed\n");

0 commit comments

Comments
 (0)