[PATCH 0/1] MR11730: windowscodecs: Pass pcbRead to IStream::Read() in jpeg_decoder_get_metadata_blocks().
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... -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
From: Shaun Ren <sren@codeweavers.com> Some non-conforming IStream implementations, including SharpDX, do not handle a NULL pcbRead for Read(). This causes the game "Surviving Deponia Playtest" to display a black main menu. --- dlls/windowscodecs/libjpeg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/libjpeg.c b/dlls/windowscodecs/libjpeg.c index 40119084e68..5282ae7066c 100644 --- a/dlls/windowscodecs/libjpeg.c +++ b/dlls/windowscodecs/libjpeg.c @@ -338,6 +338,7 @@ static HRESULT CDECL jpeg_decoder_get_metadata_blocks(struct decoder* iface, UIN struct decoder_block block; USHORT marker, length; ULONGLONG offset; + ULONG bytesread; BYTE header[4]; bool add_block; HRESULT hr; @@ -357,7 +358,7 @@ static HRESULT CDECL jpeg_decoder_get_metadata_blocks(struct decoder* iface, UIN memset(&results, 0, sizeof(results)); for (;;) { - if (stream_read(This->stream, header, 4, NULL) != S_OK) + if (stream_read(This->stream, header, 4, &bytesread) != S_OK || bytesread != 4) break; offset += 4; @@ -368,7 +369,7 @@ static HRESULT CDECL jpeg_decoder_get_metadata_blocks(struct decoder* iface, UIN if (marker == APP1) { /* APP1 marker might appear multiple times, it's reused for different metadata blocks. */ - if (stream_read(This->stream, header, 4, NULL) != S_OK) + if (stream_read(This->stream, header, 4, &bytesread) != S_OK || bytesread != 4) break; stream_seek(This->stream, -4, STREAM_SEEK_CUR, NULL); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
It was added with 2a167eb4ea844a090ca0247cf233633f697e3a85, in !7653. Looks like every other call to stream_read() is already correct in that regard. We could potentially have a test for this, using some stream wrapper, so that it doesn't regress later. Not sure how valuable it is. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730#note_149597
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
On Mon Aug 24 16:59:01 2026 +0000, Nikolay Sivov wrote: > It was added with 2a167eb4ea844a090ca0247cf233633f697e3a85, in !7653. > Looks like every other call to stream_read() is already correct in that > regard. We could potentially have a test for this, using some stream > wrapper, so that it doesn't regress later. Not sure how valuable it is. We might consider having the stream_read wrapper handle this implicitly, so if NULL is passed in it would: * Handle passing a non-NULL argument for pcbRead. * If fewer bytes are read than requested, return a failing hr. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730#note_149707
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11730
participants (4)
-
Esme Povirk (@madewokherd) -
Nikolay Sivov (@nsivov) -
Shaun Ren -
Shaun Ren (@shaunren)