aboutsummaryrefslogtreecommitdiffstats
path: root/unix/xserver/hw/vnc/vncExtInit.cc
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-10 14:30:37 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit337dbc392253af92b0577da062a5abc1d032b1ef (patch)
treee540dc7dc861f575d841970561651a9fac506120 /unix/xserver/hw/vnc/vncExtInit.cc
parentdde95fccca9fffff0da2dc486d639b162115bb9e (diff)
downloadtigervnc-337dbc392253af92b0577da062a5abc1d032b1ef.tar.gz
tigervnc-337dbc392253af92b0577da062a5abc1d032b1ef.zip
Return std::string instead of dynamic allocations
We mostly use classical C strings, but the memory management around them can get confusing and error prone. Let's use std::string for the cases where we need to return a newly allocated string.
Diffstat (limited to 'unix/xserver/hw/vnc/vncExtInit.cc')
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 4c1fdd4d..0292a6d1 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -348,14 +348,13 @@ int vncConnectClient(const char *addr)
return 0;
}
- char *host;
+ std::string host;
int port;
getHostAndPort(addr, &host, &port, 5500);
try {
- network::Socket* sock = new network::TcpSocket(host, port);
- delete [] host;
+ network::Socket* sock = new network::TcpSocket(host.c_str(), port);
desktop[0]->addClient(sock, true);
} catch (rdr::Exception& e) {
vlog.error("Reverse connection: %s",e.str());