WlanReasonCodeToString() tested and fixed
This commit is contained in:
parent
90b60031df
commit
0b70517ba9
@ -174,8 +174,6 @@ namespace winstd
|
|||||||
template<class _Elem, class _Traits, class _Ax>
|
template<class _Elem, class _Traits, class _Ax>
|
||||||
inline DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue, __reserved PVOID pReserved)
|
inline DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue, __reserved PVOID pReserved)
|
||||||
{
|
{
|
||||||
assert(0); // TODO: Test this code.
|
|
||||||
|
|
||||||
DWORD dwSize = 0;
|
DWORD dwSize = 0;
|
||||||
|
|
||||||
if (!::pfnWlanReasonCodeToString)
|
if (!::pfnWlanReasonCodeToString)
|
||||||
@ -189,7 +187,7 @@ inline DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Out_ std::basic_st
|
|||||||
DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved);
|
DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved);
|
||||||
if (dwResult == ERROR_SUCCESS) {
|
if (dwResult == ERROR_SUCCESS) {
|
||||||
DWORD dwLength = (DWORD)wcsnlen(szBuffer.get(), dwSize);
|
DWORD dwLength = (DWORD)wcsnlen(szBuffer.get(), dwSize);
|
||||||
if (dwLength < dwSize) {
|
if (dwLength < dwSize - 1) {
|
||||||
// Buffer was long enough.
|
// Buffer was long enough.
|
||||||
sValue.assign(szBuffer.get(), dwLength);
|
sValue.assign(szBuffer.get(), dwLength);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user