Skip to content

Commit

Permalink
[runner]Fix crashes caused by wrong setting AllowDataDiagnostics regi…
Browse files Browse the repository at this point in the history
…stry value (#37015)

* Fix setting registry value

* Prevent future similar crashes
  • Loading branch information
stefansjfw authored Jan 22, 2025
1 parent 422096b commit b6b941c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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

0 comments on commit b6b941c

Please sign in to comment.