X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/blobdiff_plain/263eeeabe5fb4d3daa8a9134371ca9a3e45875b0..9253e6af834cac30338e4fe28245cd6a7abdb7fa:/mDNSWindows/DLLX/StringServices.cpp diff --git a/mDNSWindows/DLLX/StringServices.cpp b/mDNSWindows/DLLX/StringServices.cpp index f00750d..87f7aa9 100755 --- a/mDNSWindows/DLLX/StringServices.cpp +++ b/mDNSWindows/DLLX/StringServices.cpp @@ -288,57 +288,57 @@ exit: extern BOOL VariantToByteArray - ( - VARIANT * inVariant, - std::vector< BYTE > & outArray - ) - { + BOOL ok = TRUE; - SAFEARRAY * psa = NULL; - - BYTE * pData = NULL; - - ULONG cElements = 0; - - HRESULT hr; - - BOOL ok = TRUE; - - - - require_action( V_VT( inVariant ) == ( VT_ARRAY|VT_UI1 ), exit, ok = FALSE ); - - psa = V_ARRAY( inVariant ); + if ( V_VT( inVariant ) == VT_BSTR ) + { + BSTR bstr = V_BSTR( inVariant ); + std::string utf8; - require_action( psa, exit, ok = FALSE ); + BSTRToUTF8( bstr, utf8 ); - require_action( SafeArrayGetDim( psa ) == 1, exit, ok = FALSE ); + outArray.reserve( utf8.size() ); + outArray.assign( utf8.begin(), utf8.end() ); + } + else if ( V_VT( inVariant ) == VT_ARRAY ) + { + SAFEARRAY * psa = NULL; + BYTE * pData = NULL; + ULONG cElements = 0; + HRESULT hr; + + psa = V_ARRAY( inVariant ); - hr = SafeArrayAccessData( psa, ( LPVOID* )&pData ); + require_action( psa, exit, ok = FALSE ); - require_action( hr == S_OK, exit, ok = FALSE ); + require_action( SafeArrayGetDim( psa ) == 1, exit, ok = FALSE ); - cElements = psa->rgsabound[0].cElements; + hr = SafeArrayAccessData( psa, ( LPVOID* )&pData ); - outArray.reserve( cElements ); + require_action( hr == S_OK, exit, ok = FALSE ); - outArray.assign( cElements, 0 ); + cElements = psa->rgsabound[0].cElements; - memcpy( &outArray[ 0 ], pData, cElements ); + outArray.reserve( cElements ); - SafeArrayUnaccessData( psa ); + outArray.assign( cElements, 0 ); + memcpy( &outArray[ 0 ], pData, cElements ); + SafeArrayUnaccessData( psa ); + } + else + { + ok = FALSE; + } exit: - - return ok; } \ No newline at end of file