Merge pull request #23490 from Faless/lws_client_memfix

Fix access to freed mem in WS client after #23241
This commit is contained in:
Rémi Verschelde 2018-11-10 22:18:42 +01:00 committed by GitHub
commit c02cd5139f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,12 +90,13 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
i.ssl_connection = 0;
}
// This String needs to survive till we call lws_client_connect_via_info
String addr_str = (String)addr;
i.address = addr_str.ascii().get_data();
i.host = p_host.utf8().get_data();
i.path = p_path.utf8().get_data();
// These CharStrings needs to survive till we call lws_client_connect_via_info
CharString addr_ch = ((String)addr).ascii();
CharString host_ch = p_host.utf8();
CharString path_ch = p_path.utf8();
i.address = addr_ch.get_data();
i.host = host_ch.get_data();
i.path = path_ch.get_data();
i.port = p_port;
lws_client_connect_via_info(&i);