3852: Fix (harmless) array OOB access when no pings were cached r=def- a=heinrich5991

Use `vector.data()` instead of `&vector[0]` to get access to the
underlying array.

Fixes #3850.

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
bors[bot] 2021-05-27 15:42:06 +00:00 committed by GitHub
commit dbf1624a9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -197,7 +197,7 @@ void CServerBrowserPingCache::GetPingCache(const CEntry **ppEntries, int *pNumEn
}
m_aNewEntries.clear();
}
*ppEntries = &m_aEntries[0];
*ppEntries = m_aEntries.data();
*pNumEntries = m_aEntries.size();
}