strsafe is a crock that does not follow its own documentation. Switch to the equivalent vcrt functions instead.
This commit is contained in:
parent
d258ac1d1d
commit
1f90366edd
|
@ -73,30 +73,13 @@ static WCHAR *strfcore(BOOL recursing, const WCHAR *format, va_list ap)
|
||||||
return emptyUTF16();
|
return emptyUTF16();
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
hr = StringCchVPrintfExW(NULL, 0,
|
n = _vscwprintf(format, ap2);
|
||||||
NULL, &n,
|
|
||||||
STRSAFE_IGNORE_NULLS,
|
|
||||||
format, ap2);
|
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
if (hr != S_OK && hr != STRSAFE_E_INSUFFICIENT_BUFFER) {
|
n++; // terminating L'\0'
|
||||||
if (!recursing)
|
|
||||||
logHRESULT(L"error determining needed buffer size", hr);
|
|
||||||
return emptyUTF16();
|
|
||||||
}
|
|
||||||
|
|
||||||
// n includes the terminating L'\0'
|
|
||||||
buf = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
|
buf = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
|
||||||
|
// includes terminating L'\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
||||||
hr = StringCchVPrintfExW(buf, n, // TODO what about this?
|
vswprintf_s(buf, n, format, ap);
|
||||||
NULL, NULL,
|
|
||||||
0,
|
|
||||||
format, ap);
|
|
||||||
if (hr != S_OK) {
|
|
||||||
if (!recursing)
|
|
||||||
logLastError(L"error formatting string", hr);
|
|
||||||
// and return an empty string
|
|
||||||
*buf = L'\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
#include <d2d1.h>
|
#include <d2d1.h>
|
||||||
#include <dwrite.h>
|
#include <dwrite.h>
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
Loading…
Reference in New Issue