# zstandard: fix division by zero when using RingBuffer · gitcafe/zig

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

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

Visibility: public

Requested revision: 138a35df8f434115be04641b1df29514b0ef1cb8

Requested commit: 138a35df8f434115be04641b1df29514b0ef1cb8

Commit: 138a35df8f434115be04641b1df29514b0ef1cb8

Tree: 15ff4de3ba769e5c1a3b4b9f11202cbc157d005b

Author: dweiller

Committer: Andrew Kelley

## Message

```
zstandard: fix division by zero when using RingBuffer

This change fixes some division-by-zero bugs introduced by the optimized
ring buffer read/write functions in d8c067966.

There are edge cases where decompression can use a length zero ring
buffer as the size of the ring buffer used is exactly the the window
size specified by a Zstandard frame, and this can be zero. Switching
away from loops to mem copies means that we need to ensure ring buffers
do not have length zero ring when attempting to read/write from them.

```

## Parents

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

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