1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-10-27 05:24:17 -04:00

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

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) { xcb_atom_t get_atom_cached(struct atom *a, const char *key, size_t keylen) {
auto atoms = container_of(a, struct atom_impl, base); 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) { const char *get_atom_name(struct atom *a, xcb_atom_t atom, xcb_connection_t *c) {