Replace rfb::strDup by safe_strdup and remove rfb::strFree in favor of free()
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3889 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/tx/TXButton.h b/unix/tx/TXButton.h
index b747279..59a8430 100644
--- a/unix/tx/TXButton.h
+++ b/unix/tx/TXButton.h
@@ -59,7 +59,7 @@
// setText() changes the text in the button.
void setText(const char* text_) {
- text.buf = rfb::strDup(text_);
+ text.buf = safe_strdup(text_);
int textWidth = XTextWidth(defaultFS, text.buf, strlen(text.buf));
int textHeight = (defaultFS->ascent + defaultFS->descent);
int newWidth = __rfbmax(width(), textWidth + xPad*2 + bevel*2);
diff --git a/unix/tx/TXLabel.h b/unix/tx/TXLabel.h
index 3d5200d..ebb8403 100644
--- a/unix/tx/TXLabel.h
+++ b/unix/tx/TXLabel.h
@@ -47,7 +47,7 @@
// setText() changes the text in the label.
void setText(const char* text_) {
- text.buf = rfb::strDup(text_);
+ text.buf = safe_strdup(text_);
lines = 0;
int lineStart = 0;
int textWidth = 0;
diff --git a/unix/tx/TXMenu.cxx b/unix/tx/TXMenu.cxx
index 92712f5..df57daf 100644
--- a/unix/tx/TXMenu.cxx
+++ b/unix/tx/TXMenu.cxx
@@ -56,7 +56,7 @@
void TXMenu::addEntry(const char* text_, long id_)
{
assert(nEntries < maxEntries);
- text[nEntries] = rfb::strDup(text_);
+ text[nEntries] = safe_strdup(text_);
checked[nEntries] = false;
id[nEntries++] = id_;
int tw = 0;
diff --git a/unix/tx/TXWindow.cxx b/unix/tx/TXWindow.cxx
index 2b535df..1b695e5 100644
--- a/unix/tx/TXWindow.cxx
+++ b/unix/tx/TXWindow.cxx
@@ -93,7 +93,7 @@
static char tickBits[] = { 0x80, 0xc0, 0xe2, 0x76, 0x3e, 0x1c, 0x08, 0x00};
tick = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), tickBits,
tickSize, tickSize);
- defaultWindowClass = rfb::strDup(defaultWindowClass_);
+ defaultWindowClass = safe_strdup(defaultWindowClass_);
}
void TXWindow::handleXEvents(Display* dpy)
diff --git a/unix/vncviewer/CConn.cxx b/unix/vncviewer/CConn.cxx
index 8231f4c..efc3c33 100644
--- a/unix/vncviewer/CConn.cxx
+++ b/unix/vncviewer/CConn.cxx
@@ -221,8 +221,8 @@
PasswdDialog dlg(dpy, title.buf, !user);
if (!dlg.show()) throw rfb::Exception("Authentication cancelled");
if (user)
- *user = strDup(dlg.userEntry.getText());
- *password = strDup(dlg.passwdEntry.getText());
+ *user = safe_strdup(dlg.userEntry.getText());
+ *password = safe_strdup(dlg.passwdEntry.getText());
}
diff --git a/unix/vncviewer/vncviewer.cxx b/unix/vncviewer/vncviewer.cxx
index 4a47788..203df9a 100644
--- a/unix/vncviewer/vncviewer.cxx
+++ b/unix/vncviewer/vncviewer.cxx
@@ -218,7 +218,7 @@
if (**vncServerName != '\0')
*remoteHost = *vncServerName;
- *gatewayHost = strDup (via.getValueStr ());
+ *gatewayHost = safe_strdup (via.getValueStr ());
*vncServerName = new char[50];
sprintf (*vncServerName, "localhost::%d", localPort);
}
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index ec2fd76..3e555ce 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -101,7 +101,7 @@
const char* userName,
char** reason) {
if (queryConnectSock) {
- *reason = strDup("Another connection is currently being queried.");
+ *reason = safe_strdup("Another connection is currently being queried.");
return VNCServerST::REJECT;
}
if (!userName) userName = "(anonymous)";
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index 66c92d2..e8e4949 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -219,7 +219,7 @@
char* XserverDesktop::substitute(const char* varName)
{
if (strcmp(varName, "$$") == 0) {
- return rfb::strDup("$");
+ return safe_strdup("$");
}
if (strcmp(varName, "$PORT") == 0) {
char* str = new char[10];
@@ -247,7 +247,7 @@
return str;
}
if (strcmp(varName, "$DESKTOP") == 0) {
- return rfb::strDup(server->getName());
+ return safe_strdup(server->getName());
}
if (strcmp(varName, "$DISPLAY") == 0) {
struct utsname uts;
@@ -260,7 +260,7 @@
}
if (strcmp(varName, "$USER") == 0) {
struct passwd* user = getpwuid(getuid());
- return rfb::strDup(user ? user->pw_name : "?");
+ return safe_strdup(user ? user->pw_name : "?");
}
return 0;
}
@@ -270,13 +270,13 @@
const char* userName,
char** reason) {
if (queryConnectId) {
- *reason = strDup("Another connection is currently being queried.");
+ *reason = safe_strdup("Another connection is currently being queried.");
return rfb::VNCServerST::REJECT;
}
queryConnectAddress.replaceBuf(sock->getPeerAddress());
if (!userName)
userName = "(anonymous)";
- queryConnectUsername.replaceBuf(strDup(userName));
+ queryConnectUsername.replaceBuf(safe_strdup(userName));
queryConnectId = sock;
vncQueryConnect(this, sock);
return rfb::VNCServerST::PENDING;