# Fix segfault when drawing paths \(\#4084\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/0cfec6e713e820f4f7d48ecbeb16e7eaca92080d)

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

Visibility: public

Requested revision: 0cfec6e713e820f4f7d48ecbeb16e7eaca92080d

Requested commit: 0cfec6e713e820f4f7d48ecbeb16e7eaca92080d

Commit: 0cfec6e713e820f4f7d48ecbeb16e7eaca92080d

Tree: 890199126948810cbc316526b5274ff7d2b6c50c

Author: Antonio Scandurra

Committer: GitHub

## Message

```
Fix segfault when drawing paths (#4084)

Previously, we were using `size_of` but passing the wrong type in
(`MonochromeSprite` instead of `PathSprite`). This caused us to read
outside of the `sprites` smallvec and triggered the segfault. This
reverts #4078 because I don't think using a `SmallVec` was the issue (it
might have masked this problem though, because we would most of the time
copy from the stack and not from the heap).

With this pull request we are also fixing another potential source of
segfaults, due to checking if we exhausted the instance buffer too late
when drawing underlines.

Release Notes:

- Fixed a crash that could happen during rendering.
```

## Parents

- [3789e7ebccf1a76105c2fc82fbd331b433c2b15a](https://git.cafe/gitcafe/zed/commit/3789e7ebccf1a76105c2fc82fbd331b433c2b15a?format=markdown)

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

[Source at this commit](https://git.cafe/gitcafe/zed/tree/0cfec6e713e820f4f7d48ecbeb16e7eaca92080d?format=markdown)
