atom: fix segfault when atom is not in the cache

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-19 21:48:35 +00:00
parent 592c2212f9
commit 0551d63b5f
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 5 additions and 1 deletions

View File

@ -75,7 +75,11 @@ xcb_atom_t get_atom(struct atom *a, const char *key, size_t keylen, xcb_connecti
xcb_atom_t get_atom_cached(struct atom *a, const char *key, size_t keylen) {
auto atoms = container_of(a, struct atom_impl, base);
return cache_entry(cache_get(&atoms->c, key, keylen), struct atom_entry, entry)->atom;
auto entry = cache_get(&atoms->c, key, keylen);
if (!entry) {
return XCB_NONE;
}
return cache_entry(entry, struct atom_entry, entry)->atom;
}
const char *get_atom_name(struct atom *a, xcb_atom_t atom, xcb_connection_t *c) {