diff --git a/winpr/libwinpr/registry/registry.c b/winpr/libwinpr/registry/registry.c index 7422d8ba3..46a6ee32d 100644 --- a/winpr/libwinpr/registry/registry.c +++ b/winpr/libwinpr/registry/registry.c @@ -385,11 +385,13 @@ LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWOR case REG_DWORD_BIG_ENDIAN: case REG_QWORD: case REG_DWORD: - return reg_read_int(pValue, lpData, lpcbData); + status = reg_read_int(pValue, lpData, lpcbData); + goto end; case REG_SZ: { const size_t length = strnlen(pValue->data.string, UINT32_MAX) * sizeof(WCHAR); + status = ERROR_SUCCESS; if (lpData != NULL) { DWORD size = 0; @@ -404,14 +406,13 @@ LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWOR size = *lpcbData; *lpcbData = (DWORD)length; if (size < length) - return ERROR_MORE_DATA; + status = ERROR_MORE_DATA; if (ConvertUtf8NToWChar(pValue->data.string, length, cnv.wc, length) < 0) - return ERROR_OUTOFMEMORY; + status = ERROR_OUTOFMEMORY; } else if (lpcbData) *lpcbData = (UINT32)length; - status = ERROR_SUCCESS; goto end; } default: