# HG changeset patch # User Markus Mützel # Date 1635701133 -3600 # Node ID 3c60814448ea063ab891c8d89267264448bd3f49 # Parent de3275323dff344962e81a6082ab6934e9ca520e 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. diff -r de3275323dff -r 3c60814448ea libinterp/corefcn/sysdep.cc --- 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 (data))); else if (type == REG_SZ || type == REG_EXPAND_SZ) - value = string_vector (sys::u8_from_wstring (reinterpret_cast (data))); + { + // strings in registry might not be zero terminated + std::wstring reg_string + = std::wstring (reinterpret_cast (data), + length / sizeof (wchar_t)); + value = string_vector (sys::u8_from_wstring (reg_string)); + } return result; }