aboutsummaryrefslogtreecommitdiffstats
path: root/unix/vncpasswd/vncpasswd.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-13 11:14:21 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit5c1ac16776cd9f2a75e31086755e72186b3b3d41 (patch)
tree234a54c7f11c25ba59f8487118d13eb550c1cc64 /unix/vncpasswd/vncpasswd.cxx
parent1af2a56f7583b301890f8ea213f262782cc3c9f1 (diff)
downloadtigervnc-5c1ac16776cd9f2a75e31086755e72186b3b3d41.tar.gz
tigervnc-5c1ac16776cd9f2a75e31086755e72186b3b3d41.zip
Return static char buffer from some methods
This mimics how some system functions (like inet_ntop()) work, and avoids complexity around ownership of the returned string buffer. The downside is that the string must be consumed directly as it will be overwritten on the next call, but that is not an issue with the current usage.
Diffstat (limited to 'unix/vncpasswd/vncpasswd.cxx')
-rw-r--r--unix/vncpasswd/vncpasswd.cxx5
1 files changed, 2 insertions, 3 deletions
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 189577b8..c7af2588 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -146,15 +146,14 @@ int main(int argc, char** argv)
}
if (!fname) {
- char *homeDir = NULL;
- if (getvnchomedir(&homeDir) == -1) {
+ const char *homeDir = getvnchomedir();
+ if (homeDir == NULL) {
fprintf(stderr, "Can't obtain VNC home directory\n");
exit(1);
}
mkdir(homeDir, 0777);
fname = new char[strlen(homeDir) + 7];
sprintf(fname, "%spasswd", homeDir);
- delete [] homeDir;
}
while (true) {