# Reader.defaultDiscard: Fix for use with an indirect reader · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/21f9f378f165a762059f12bc3d789c731037c8b6)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 21f9f378f165a762059f12bc3d789c731037c8b6

Requested commit: 21f9f378f165a762059f12bc3d789c731037c8b6

Commit: 21f9f378f165a762059f12bc3d789c731037c8b6

Tree: e29842646e88a4082df650cb10a4df8fa71803c5

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
Reader.defaultDiscard: Fix for use with an indirect reader

If a Reader implementation implements `stream` by ignoring the Writer, writing directly to its internal buffer, and returning 0, then `defaultDiscard` would not update `seek` and also return 0, which is incorrect and can cause `discardShort` to violate the contract of `VTable.discard` by calling into `vtable.discard` with a non-empty buffer.

This commit fixes the problem by advancing seek up to the limit after the stream call. This logic could likely be somewhat simplified in the future depending on how #25170 is resolved.

```

## Parents

- [2ea55d7153b9832e7f00c8a85ca4941ccde6b0d6](https://git.cafe/gitcafe/zig/commit/2ea55d7153b9832e7f00c8a85ca4941ccde6b0d6?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/21f9f378f165a762059f12bc3d789c731037c8b6?format=markdown)
