# HG changeset patch # User Markus Mützel # Date 1641930215 -3600 # Node ID 51770116f835fb081dfc9a23b39c6092b1ed59fa # Parent 2a234181057be77ba4def4df19fa8bee0c22e954 winqueryreg: Don't include terminating zero in string. * libinterp/corefcn/sysdep.cc (get_regkey_value): Don't include terminating zero in string. See: https://octave.discourse.group/t/2104 diff -r 2a234181057b -r 51770116f835 libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc Tue Jan 11 19:24:47 2022 +0100 +++ b/libinterp/corefcn/sysdep.cc Tue Jan 11 20:43:35 2022 +0100 @@ -951,9 +951,10 @@ else if (type == REG_SZ || type == REG_EXPAND_SZ) { // strings in registry might not be zero terminated + wchar_t *dataw = reinterpret_cast (data); + DWORD lengthw = length / sizeof (wchar_t); std::wstring reg_string - = std::wstring (reinterpret_cast (data), - length / sizeof (wchar_t)); + = std::wstring (dataw, lengthw - (dataw[lengthw-1]==0)); value = string_vector (sys::u8_from_wstring (reg_string)); }