# Fix std.HashMap.remove returning incorrect KV · gitcafe/zig

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

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

Visibility: public

Requested revision: 6a78b315b2112e372b48ba7399ea9cddadbe65b6

Requested commit: 6a78b315b2112e372b48ba7399ea9cddadbe65b6

Commit: 6a78b315b2112e372b48ba7399ea9cddadbe65b6

Tree: 4d196cae30369468c1912139e6f8a7f720d45913

Author: Ryan Liptak

Committer: Andrew Kelley

## Message

```
Fix std.HashMap.remove returning incorrect KV

Now returns a copy of the removed kv instead of a pointer to the removed kv. The removed kv gets overwritten when shifting the hash map after the removal, so returning a pointer to it will have another kv's values in it after the return.

This bug had some nasty downstream effects in things like BufSet and BufMap where delete would free a still in-use KV and leave the actually removed KV un-free'd.

```

## Parents

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

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