aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/SSecurityVncAuth.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-15 16:55:34 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit2047dae22fb862ff43309ebb4fe2b9e7d6ce6153 (patch)
tree975687d97e31e677f827e0f586a349868e6a1e65 /common/rfb/SSecurityVncAuth.cxx
parentea6afa9b791e3782455a829f97515fa721edd522 (diff)
downloadtigervnc-2047dae22fb862ff43309ebb4fe2b9e7d6ce6153.tar.gz
tigervnc-2047dae22fb862ff43309ebb4fe2b9e7d6ce6153.zip
Return std::vector instead of dynamic allocation
This makes memory management more clear and robust when using these helper functions.
Diffstat (limited to 'common/rfb/SSecurityVncAuth.cxx')
-rw-r--r--common/rfb/SSecurityVncAuth.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx
index b70f0668..d035f97f 100644
--- a/common/rfb/SSecurityVncAuth.cxx
+++ b/common/rfb/SSecurityVncAuth.cxx
@@ -123,7 +123,12 @@ VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name,
void VncAuthPasswdParameter::getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword) {
ObfuscatedPasswd obfuscated, obfuscatedReadOnly;
- getData((uint8_t**)&obfuscated.buf, &obfuscated.length);
+ std::vector<uint8_t> data = getData();
+ obfuscated.length = data.size();
+ if (!data.empty()) {
+ obfuscated.buf = new char[data.size()];
+ memcpy(obfuscated.buf, data.data(), data.size());
+ }
if (obfuscated.length == 0) {
if (passwdFile) {