Mercurial > octave
changeset 30265:3c60814448ea
winqueryreg: Strings in Windows registry might not be zero terminated.
* libinterp/corefcn/sysdep.cc (get_regkey_value): Use wstring constructor with
buffer and size to also handle non-zero terminated strings.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 31 Oct 2021 18:25:33 +0100 |
parents | de3275323dff |
children | 38ee67b5ec9f |
files | libinterp/corefcn/sysdep.cc |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc Sun Oct 31 18:06:22 2021 +0100 +++ b/libinterp/corefcn/sysdep.cc Sun Oct 31 18:25:33 2021 +0100 @@ -949,7 +949,13 @@ if (type == REG_DWORD) value = octave_int32 (*(reinterpret_cast<DWORD *> (data))); else if (type == REG_SZ || type == REG_EXPAND_SZ) - value = string_vector (sys::u8_from_wstring (reinterpret_cast<wchar_t *> (data))); + { + // strings in registry might not be zero terminated + std::wstring reg_string + = std::wstring (reinterpret_cast<wchar_t *> (data), + length / sizeof (wchar_t)); + value = string_vector (sys::u8_from_wstring (reg_string)); + } return result; }