[PATCH v5 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... -- v5: 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. Fixes: 2a167eb4ea844a090ca0247cf233633f697e3a85 --- dlls/windowscodecs/wincodecs_common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/windowscodecs/wincodecs_common.c b/dlls/windowscodecs/wincodecs_common.c index 8da1bfed20c..a60e4b70d98 100644 --- a/dlls/windowscodecs/wincodecs_common.c +++ b/dlls/windowscodecs/wincodecs_common.c @@ -188,7 +188,18 @@ 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); + 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. */ + if (!bytes_read) + bytes_read = &nread; + + hr = IStream_Read(stream, buffer, read, bytes_read); + if (SUCCEEDED(hr) && *bytes_read != read) + return S_FALSE; + 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
On Mon Aug 24 18:11:19 2026 +0000, Shaun Ren wrote:
changed this line in [version 5 of the diff](/wine/wine/-/merge_requests/11730/diffs?diff_id=292973&start_sha=e15407d44be385a43d9160699bea055c1f3b9d34#e8482f4c1783af5184283bfa69f723009098b2da_206_191) Changed to `S_FALSE`.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730#note_149731
participants (2)
-
Shaun Ren -
Shaun Ren (@shaunren)