[PATCH v3 0/1] MR11730: windowscodecs: Always pass a valid pcbRead pointer to IStream::Read().
Some non-conforming IStream implementations, including SharpDX, do not handle a NULL pcbRead for Read() [^1]. This causes the game "Surviving Deponia Playtest" to display a black main menu. [^1]: https://github.com/sharpdx/SharpDX/blob/ab36f12303e24aa60fe804866617716b6ded... -- v3: windowscodecs: Always pass a valid pcbRead pointer to IStream::Read(). https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
From: Shaun Ren <sren@codeweavers.com> Some non-conforming IStream implementations, such as SharpDX, do not handle a NULL pcbRead for Read(). This causes the game "Surviving Deponia Playtest" to display a black main menu. --- dlls/windowscodecs/wincodecs_common.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dlls/windowscodecs/wincodecs_common.c b/dlls/windowscodecs/wincodecs_common.c index 8da1bfed20c..67dafbf2ae1 100644 --- a/dlls/windowscodecs/wincodecs_common.c +++ b/dlls/windowscodecs/wincodecs_common.c @@ -188,7 +188,22 @@ HRESULT CDECL stream_getsize(IStream *stream, ULONGLONG *size) HRESULT CDECL stream_read(IStream *stream, void *buffer, ULONG read, ULONG *bytes_read) { - return IStream_Read(stream, buffer, read, bytes_read); + if (bytes_read) + { + return IStream_Read(stream, buffer, read, bytes_read); + } + else + { + ULONG nread; + HRESULT hr; + + /* Ensure that we always pass a non-NULL bytes_read pointer, as some + * implementations (e.g. SharpDX) can't handle it being NULL. */ + hr = IStream_Read(stream, buffer, read, &nread); + if (SUCCEEDED(hr) && nread != read) + return E_FAIL; + return hr; + } } HRESULT CDECL stream_seek(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG *new_position) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
participants (2)
-
Shaun Ren -
Shaun Ren (@shaunren)