From 2f577c1b719789155e127ddbbf1a22aa6912c1e7 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Tue, 19 Dec 2017 12:04:00 +0100 Subject: [PATCH] libobs: Make get_reg_dword handle missing keys Previously if the key didn't exist it would return uninitialized stack memory. Reported at https://obsproject.com/forum/threads/obs-freezes-computer-on-startup-sometimes.78030/#post-330590 --- libobs/obs-windows.c | 24 +++++++++++++++++++----- libobs/util/platform-windows.c | 6 +++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libobs/obs-windows.c b/libobs/obs-windows.c index 62d08c249..2c2d445b1 100644 --- a/libobs/obs-windows.c +++ b/libobs/obs-windows.c @@ -220,17 +220,31 @@ static void log_gaming_features(void) L"AllowAutoGameMode", &game_mode_enabled); blog(LOG_INFO, "Windows 10 Gaming Features:"); - blog(LOG_INFO, "\tGame Bar: %s", + if (game_bar_enabled.status == ERROR_SUCCESS) { + blog(LOG_INFO, "\tGame Bar: %s", (bool)game_bar_enabled.return_value ? "On" : "Off"); - blog(LOG_INFO, "\tGame DVR Allowed: %s", + } + + if (game_dvr_allowed.status == ERROR_SUCCESS) { + blog(LOG_INFO, "\tGame DVR Allowed: %s", (bool)game_dvr_allowed.return_value ? "Yes" : "No"); - blog(LOG_INFO, "\tGame DVR: %s", + } + + if (game_dvr_enabled.status == ERROR_SUCCESS) { + blog(LOG_INFO, "\tGame DVR: %s", (bool)game_dvr_enabled.return_value ? "On" : "Off"); - blog(LOG_INFO, "\tGame DVR Background Recording: %s", + } + + if (game_dvr_bg_recording.status == ERROR_SUCCESS) { + blog(LOG_INFO, "\tGame DVR Background Recording: %s", (bool)game_dvr_bg_recording.return_value ? "On" : "Off"); - blog(LOG_INFO, "\tGame Mode: %s", + } + + if (game_mode_enabled.status == ERROR_SUCCESS) { + blog(LOG_INFO, "\tGame Mode: %s", (bool)game_mode_enabled.return_value ? "On" : "Off"); + } } void log_system_info(void) diff --git a/libobs/util/platform-windows.c b/libobs/util/platform-windows.c index ff4d39ccd..5435b680c 100644 --- a/libobs/util/platform-windows.c +++ b/libobs/util/platform-windows.c @@ -810,8 +810,12 @@ void get_reg_dword(HKEY hkey, LPCWSTR sub_key, LPCWSTR value_name, status = RegOpenKeyEx(hkey, sub_key, 0, KEY_READ, &key); - if (status != ERROR_SUCCESS) + if (status != ERROR_SUCCESS) { + info->status = status; + info->size = 0; + info->return_value = 0; return; + } reg.size = sizeof(reg.return_value);