From a4f5cecad8f2873e0e6e14b9a20698950c3224f0 Mon Sep 17 00:00:00 2001 From: Mammon Baloch <154027819+starlightretailceo@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:20:12 -0700 Subject: [PATCH] Fix driver store path conversion --- src/dxcore.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dxcore.c b/src/dxcore.c index 4d42204d..8df68975 100644 --- a/src/dxcore.c +++ b/src/dxcore.c @@ -189,7 +189,15 @@ static int dxcore_query_adapter_driverstore(struct dxcore_lib* pLib, unsigned in free(pValue); return (-1); } - wcstombs(*ppDriverStorePath, pOutput, outputSize); + /* + * wcstombs() expects the size of the destination buffer in bytes. The + * buffer allocated above is `outputSize + 1` bytes long, which includes + * room for the terminating NUL byte. Passing only `outputSize` could + * prevent the terminator from being written when the converted string + * length equals `outputSize`. Use the full buffer size here to ensure + * the resulting string is always NUL terminated. + */ + wcstombs(*ppDriverStorePath, pOutput, outputSize + 1); free(pValue);