1 diff --git a/common/rfb/Password.cxx b/common/rfb/Password.cxx
2 index e4a508c..f555c57 100644
3 --- a/common/rfb/Password.cxx
4 +++ b/common/rfb/Password.cxx
5 @@ -55,7 +55,7 @@ PlainPasswd::~PlainPasswd() {
7 void PlainPasswd::replaceBuf(char* b) {
9 - memset(buf, 0, strlen(buf));
10 + memset(buf, 0, length ? length : strlen(buf));
11 CharArray::replaceBuf(b);
14 diff --git a/common/rfb/util.h b/common/rfb/util.h
15 index 3100f90..764692a 100644
16 --- a/common/rfb/util.h
17 +++ b/common/rfb/util.h
18 @@ -51,16 +51,21 @@ namespace rfb {
19 CharArray() : buf(0) {}
20 CharArray(char* str) : buf(str) {} // note: assumes ownership
21 CharArray(size_t len) {
23 buf = new char[len]();
32 void format(const char *fmt, ...) __printf_attr(2, 3);
33 // Get the buffer pointer & clear it (i.e. caller takes ownership)
34 char* takeBuf() {char* tmp = buf; buf = 0; return tmp;}
35 - void replaceBuf(char* b) {delete [] buf; buf = b;}
36 + void replaceBuf(char* b) {if (buf) delete [] buf; buf = b;}
40 CharArray(const CharArray&);
41 CharArray& operator=(const CharArray&);