# debug: fix edge cases in macOS debug symbol lookup · gitcafe/zig

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

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

Visibility: public

Requested revision: 23d148e5c7ab036ef686606f11a2343940890f5a

Requested commit: 23d148e5c7ab036ef686606f11a2343940890f5a

Commit: 23d148e5c7ab036ef686606f11a2343940890f5a

Tree: 5b8c3d54cb44c0d691dcda5b9c1b5cbba2e17ed0

Author: John Schmidt

Committer: Andrew Kelley

## Message

```
debug: fix edge cases in macOS debug symbol lookup

This commit fixes two related things:

1. If the loop goes all the way through the slice without a match, on
   the last iteration `mid == symbols.len - 1` which causes
   `&symbols[mid + 1]` to be out of bounds. End one step before that
   instead.

2. If the address we're looking for is greater than the address of the
   last symbol in the slice, we now match it to that symbol. Previously,
   we would miss this case since we only matched if the address was _in
   between_ the address of two symbols.

```

## Parents

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

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