diff --git a/rejistry++/src/RegistryByteBuffer.cpp b/rejistry++/src/RegistryByteBuffer.cpp index f3e781b77d78349035cb0d8d768f7eeee4fce5af..04202c0aba5ceb678d396dcf3891f9145b6700fb 100644 --- a/rejistry++/src/RegistryByteBuffer.cpp +++ b/rejistry++/src/RegistryByteBuffer.cpp @@ -77,9 +77,13 @@ namespace Rejistry { std::wstring RegistryByteBuffer::getUTF16String(const uint32_t offset, const uint32_t length) const { ByteBuffer::ByteArray &data = getData(offset, length); - std::wstring_convert<std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t> conv; - return conv.from_bytes(reinterpret_cast<const char*>(&data[0]), reinterpret_cast<const char *>(&data[0] + length)); + std::wstring result = conv.from_bytes(reinterpret_cast<const char*>(&data[0]), reinterpret_cast<const char*>(&data[0] + length)); + std::size_t firstNull = result.find_first_of(L'\0'); + if (firstNull != std::string::npos) { + result.erase(firstNull, result.size()); + } + return result; } ByteBuffer::ByteArray RegistryByteBuffer::getData() const { diff --git a/rejistry++/src/RegistryKey.cpp b/rejistry++/src/RegistryKey.cpp index 3753f5e0ff9fe49956207cfe8e300632630dedef..d1a2a542f713211ffd47ac7d485ab80b5965aa9b 100644 --- a/rejistry++/src/RegistryKey.cpp +++ b/rejistry++/src/RegistryKey.cpp @@ -35,6 +35,13 @@ namespace Rejistry { _nk = new NKRecord(*(rk._nk)); } + RegistryKey& RegistryKey::operator=(const RegistryKey & rk) { + if (this != &rk) { + _nk = new NKRecord(*(rk._nk)); + } + return *this; + } + RegistryKey::~RegistryKey() { if (_nk != NULL) { delete _nk; diff --git a/rejistry++/src/RegistryKey.h b/rejistry++/src/RegistryKey.h index 4c13454b8341702c0540ae9cae242950860da939..9d7f0dd8060e10a4cf8ac540210116659c481d9c 100644 --- a/rejistry++/src/RegistryKey.h +++ b/rejistry++/src/RegistryKey.h @@ -47,6 +47,7 @@ namespace Rejistry { RegistryKey(NKRecord* nk) { _nk = nk; } RegistryKey(const RegistryKey& ); + RegistryKey& operator=(const RegistryKey &); virtual ~RegistryKey(); @@ -97,7 +98,6 @@ namespace Rejistry { private: RegistryKey(); - RegistryKey& operator=(const RegistryKey &); NKRecord * _nk; };