From d79258c2e71e959d573a08bc04aa5c727d3347f8 Mon Sep 17 00:00:00 2001 From: uno1982 Date: Sat, 3 May 2025 04:47:31 -0500 Subject: [PATCH] Fix: Windows OS.get_unique_id() null termination issue use ascii for encoding-neutral check buffer size as well --- platform/windows/os_windows.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 1095831709..19c5f67ec0 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2437,7 +2437,9 @@ String OS_Windows::get_user_data_dir(const String &p_user_dir) const { String OS_Windows::get_unique_id() const { HW_PROFILE_INFOA HwProfInfo; ERR_FAIL_COND_V(!GetCurrentHwProfileA(&HwProfInfo), ""); - return String::ascii(Span((HwProfInfo.szHwProfileGuid), HW_PROFILE_GUIDLEN)); + + // Note: Windows API returns a GUID with null termination. + return String::ascii(Span(HwProfInfo.szHwProfileGuid, strnlen(HwProfInfo.szHwProfileGuid, HW_PROFILE_GUIDLEN))); } bool OS_Windows::_check_internal_feature_support(const String &p_feature) {