Module: wine Branch: master Commit: c664e9f4942a9fa5d31366aabfeb056861519aae URL: http://source.winehq.org/git/wine.git/?a=commit;h=c664e9f4942a9fa5d31366aabf...
Author: Juan Lang juan.lang@gmail.com Date: Wed Aug 19 19:18:26 2009 -0700
ole32: On big endian machines, copy strings to little endian order without mucking with the map they're stored in.
---
dlls/ole32/stg_prop.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c index 381e079..93653bb 100644 --- a/dlls/ole32/stg_prop.c +++ b/dlls/ole32/stg_prop.c @@ -1477,6 +1477,25 @@ static void PropertyStorage_MakePropertyIdOffset(DWORD propid, DWORD dwOffset, offsetof(PROPERTYIDOFFSET, dwOffset), dwOffset); }
+static inline HRESULT PropertStorage_WriteWStringToStream(IStream *stm, + LPCWSTR str, DWORD len, DWORD *written) +{ +#ifdef WORDS_BIGENDIAN + WCHAR *leStr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + HRESULT hr; + + if (!leStr) + return E_OUTOFMEMORY; + memcpy(leStr, str, len * sizeof(WCHAR)); + PropertyStorage_ByteSwapString(leStr, len); + hr = IStream_Write(stm, leStr, len, written); + HeapFree(GetProcessHeap(), 0, leStr); + return hr; +#else + return IStream_Write(stm, str, len, written); +#endif +} + struct DictionaryClosure { HRESULT hr; @@ -1508,12 +1527,8 @@ static BOOL PropertyStorage_DictionaryWriter(const void *key, if (FAILED(c->hr)) goto end; c->bytesWritten += sizeof(DWORD); - /* Rather than allocate a copy, I'll swap the string to little-endian - * in-place, write it, then swap it back. - */ - PropertyStorage_ByteSwapString(key, keyLen); - c->hr = IStream_Write(This->stm, key, keyLen, &count); - PropertyStorage_ByteSwapString(key, keyLen); + c->hr = PropertStorage_WriteWStringToStream(This->stm, key, keyLen, + &count); if (FAILED(c->hr)) goto end; c->bytesWritten += keyLen;