Sanitize opacity data get from window props

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-10-31 23:18:10 +00:00
parent d7b5104fd4
commit 32e0b45255
1 changed files with 6 additions and 1 deletions

View File

@ -271,7 +271,12 @@ bool wid_get_opacity_prop(session_t *ps, Window wid, opacity_t def,
winprop_t prop = wid_get_prop(ps, wid, ps->atom_opacity, 1L, XCB_ATOM_CARDINAL, 32); winprop_t prop = wid_get_prop(ps, wid, ps->atom_opacity, 1L, XCB_ATOM_CARDINAL, 32);
if (prop.nitems) { if (prop.nitems) {
*out = *prop.data.p32; // sanitize the opacity data, if opacity is out of bounds,
// assuming they are opaque
if (*prop.data.p32 < 0 || *prop.data.p32 > OPAQUE)
*out = OPAQUE;
else
*out = *prop.data.p32;
ret = true; ret = true;
} }