From a8e84221709e8a1f270b2320e820550d75b56dbb Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 30 Oct 2025 03:02:12 +0800 Subject: [PATCH] d3d12/dozen: Use os_get_option_dup for passing to ID3D12SDKConfiguration_SetSDKVersion consecutive calling to getenv or os_get_option is invalid usage, so convert to use os_get_option_dup instead Signed-off-by: Yonggang Luo Reviewed-by: Yiwei Zhang Acked-by: Antonio Ospite Part-of: --- src/gallium/drivers/d3d12/d3d12_screen.cpp | 6 ++++-- src/microsoft/vulkan/dzn_device.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp b/src/gallium/drivers/d3d12/d3d12_screen.cpp index d30d1b4cce3..180053af988 100644 --- a/src/gallium/drivers/d3d12/d3d12_screen.cpp +++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp @@ -1421,11 +1421,13 @@ try_create_device_factory(util_dl_library *d3d12_mod) /* It's possible there's a D3D12Core.dll next to the .exe, for development/testing purposes. If so, we'll be notified * by environment variables what the relative path is and the version to use. */ - const char *d3d12core_relative_path = getenv("D3D12_AGILITY_RELATIVE_PATH"); - const char *d3d12core_sdk_version = getenv("D3D12_AGILITY_SDK_VERSION"); + char *d3d12core_relative_path = os_get_option_dup("D3D12_AGILITY_RELATIVE_PATH"); + char *d3d12core_sdk_version = os_get_option_dup("D3D12_AGILITY_SDK_VERSION"); if (d3d12core_relative_path && d3d12core_sdk_version) { (void)sdk_config->SetSDKVersion(atoi(d3d12core_sdk_version), d3d12core_relative_path); } + free(d3d12core_relative_path); + free(d3d12core_sdk_version); sdk_config->Release(); } #endif diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c index ed4ae15af2d..163168e4ba8 100644 --- a/src/microsoft/vulkan/dzn_device.c +++ b/src/microsoft/vulkan/dzn_device.c @@ -315,11 +315,13 @@ try_create_device_factory(struct util_dl_library *d3d12_mod) /* It's possible there's a D3D12Core.dll next to the .exe, for development/testing purposes. If so, we'll be notified * by environment variables what the relative path is and the version to use. */ - const char *d3d12core_relative_path = getenv("DZN_AGILITY_RELATIVE_PATH"); - const char *d3d12core_sdk_version = getenv("DZN_AGILITY_SDK_VERSION"); + char *d3d12core_relative_path = os_get_option_dup("DZN_AGILITY_RELATIVE_PATH"); + char *d3d12core_sdk_version = os_get_option_dup("DZN_AGILITY_SDK_VERSION"); if (d3d12core_relative_path && d3d12core_sdk_version) { ID3D12SDKConfiguration_SetSDKVersion(sdk_config, atoi(d3d12core_sdk_version), d3d12core_relative_path); } + free(d3d12core_relative_path); + free(d3d12core_sdk_version); ID3D12SDKConfiguration_Release(sdk_config); } #endif