mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
x: wid_get_text_prop shouldn't return 0 strings
Downstream code expect wid_get_text_prop to return at least 1 string.
However wid_get_text_prop would return 0 strings when the property is
set to an empty string.
Fixes: dc37370a66
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
6c6b1afeb3
commit
3576a92da3
2 changed files with 16 additions and 2 deletions
|
@ -543,10 +543,13 @@ int win_update_name(session_t *ps, struct managed_win *w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(wid_get_text_prop(ps, w->client_win, ps->atoms->a_NET_WM_NAME, &strlst, &nstr))) {
|
if (!(wid_get_text_prop(ps, w->client_win, ps->atoms->a_NET_WM_NAME, &strlst, &nstr))) {
|
||||||
log_trace("(%#010x): _NET_WM_NAME unset, falling back to WM_NAME.",
|
log_debug("(%#010x): _NET_WM_NAME unset, falling back to WM_NAME.",
|
||||||
w->client_win);
|
w->client_win);
|
||||||
|
|
||||||
if (!wid_get_text_prop(ps, w->client_win, ps->atoms->aWM_NAME, &strlst, &nstr)) {
|
if (!wid_get_text_prop(ps, w->client_win, ps->atoms->aWM_NAME, &strlst, &nstr)) {
|
||||||
|
log_debug("Unsetting window name for %#010x", w->client_win);
|
||||||
|
free(w->name);
|
||||||
|
w->name = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,7 +563,7 @@ int win_update_name(session_t *ps, struct managed_win *w) {
|
||||||
|
|
||||||
free(strlst);
|
free(strlst);
|
||||||
|
|
||||||
log_trace("(%#010x): client = %#010x, name = \"%s\", "
|
log_debug("(%#010x): client = %#010x, name = \"%s\", "
|
||||||
"ret = %d",
|
"ret = %d",
|
||||||
w->base.id, w->client_win, w->name, ret);
|
w->base.id, w->client_win, w->name, ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
11
src/x.c
11
src/x.c
|
@ -145,6 +145,17 @@ bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop, char **
|
||||||
nstr += 1;
|
nstr += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nstr == 0) {
|
||||||
|
// The property is set to an empty string, in that case, we return one
|
||||||
|
// string
|
||||||
|
char **strlst = malloc(sizeof(char *));
|
||||||
|
strlst[0] = "";
|
||||||
|
*pnstr = 1;
|
||||||
|
*pstrlst = strlst;
|
||||||
|
free(r);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate the pointers and the strings together
|
// Allocate the pointers and the strings together
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
if (posix_memalign(&buf, alignof(char *), length + sizeof(char *) * nstr + 1) != 0) {
|
if (posix_memalign(&buf, alignof(char *), length + sizeof(char *) * nstr + 1) != 0) {
|
||||||
|
|
Loading…
Reference in a new issue