Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runner] Fix crashes caused by wrong setting AllowDataDiagnostics registry value #37015

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public static bool GetEnabledValue()
try
{
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);

if (registryValue is not null)
{
return (int)registryValue == 1 ? true : false;
}
}
catch
{
}

if (registryValue is not null)
{
return (int)registryValue == 1 ? true : false;
}

return false;
}

Expand Down
5 changes: 2 additions & 3 deletions src/common/SettingsAPI/settings_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ namespace PTSettingsHelper
return;
}

const bool value = enabled;
const size_t buf_size = sizeof(bool);
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_QWORD, reinterpret_cast<const BYTE*>(&value), buf_size) != ERROR_SUCCESS)
const DWORD value = enabled ? 1 : 0;
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(value)) != ERROR_SUCCESS)
{
RegCloseKey(key);
return;
Expand Down
Loading