From: Sebastian Lackner Subject: kernel32: Fix calculation of returned buffer in get_registry_locale_info. Message-Id: <551E8B2B.6060709@fds-team.de> Date: Fri, 03 Apr 2015 14:44:27 +0200 Fixes a regression introduced by 8826ba1bc86fefa22c543608585ae8f3b4310a5f. We cannot decide if we have to append a terminating null char unless we have queried again with a bigger buffer. --- dlls/kernel32/locale.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) From 361510879cf894896fb11ef5274e17762d1114d0 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 3 Apr 2015 14:25:57 +0200 Subject: kernel32: Fix calculation of returned buffer in get_registry_locale_info. --- dlls/kernel32/locale.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index afc5b9d..7798b91 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -1177,6 +1177,17 @@ static INT get_registry_locale_info( struct registry_value *registry_value, LPWS status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, info, size, &size ); + /* try again with a bigger buffer when we have to return the correct size */ + if (status == STATUS_BUFFER_OVERFLOW && !buffer && size > info_size) + { + KEY_VALUE_PARTIAL_INFORMATION *new_info; + if ((new_info = HeapReAlloc( GetProcessHeap(), 0, info, size ))) + { + info = new_info; + status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, info, size, &size ); + } + } + NtClose( hkey ); if (!status) @@ -1207,8 +1218,6 @@ static INT get_registry_locale_info( struct registry_value *registry_value, LPWS if (status == STATUS_BUFFER_OVERFLOW && !buffer) { ret = (size - info_size) / sizeof(WCHAR); - if (!ret || ((WCHAR *)&info->Data)[ret-1]) - ret++; } else if (status == STATUS_OBJECT_NAME_NOT_FOUND) { -- 2.3.3