On Thu Jan 30 20:36:01 2025 +0000, Michael Stefaniuc wrote:
I'm confused about the EOF detection here. `IStream_Read()` should give you the `E_FAIL` if the stream is already at EOF. But then the read is `0`.\ So the check should be more of a `hr == E_FAIL && !read`. Assuming that any other `E_FAIL` should be still passed on. Also what should happen for an `E_FAIL` during the `i == 0` case? Aka no track read? Should that be still ignored? The short read case `read < sizeof(magic)` is already handled by the comparison of `magic` with `"MTrk"`.
`!read` was changed to `read < sizeof(magic)` because of @rbernon's suggestion: https://gitlab.winehq.org/wine/wine/-/merge_requests/5081#note_61500 . Think malformed MIDI files with trailing bytes, etc.
Also, because short read leave `magic` uninitialized, you can't then compare it to `"MTrk"`.