core: fix rare double-free when xinerama update fails

Explicitly set `xinerama_scr_regs` to `NULL` after calling free() to
avoid freeing them again.

Under normal operation we free the old xinerama screen region list on
root screen changes and allocate a new one with the updated regions.
On rare occasions — mainly reproducable by changing monitors while DPMS
is in standby — updating the region list might fail as for whatever
reason the xinerama extension is marked as inactive. This would leave
us with an invalid pointer to the already freed region list we would
then attempt to free again on the next root screen change.
This commit is contained in:
Bernd Busse 2021-08-04 17:32:44 +02:00
parent 24b4450726
commit 78e8666498
No known key found for this signature in database
GPG Key ID: 6DD2A3C48E63A5AB
1 changed files with 1 additions and 0 deletions

View File

@ -121,6 +121,7 @@ static inline void free_xinerama_info(session_t *ps) {
for (int i = 0; i < ps->xinerama_nscrs; ++i)
pixman_region32_fini(&ps->xinerama_scr_regs[i]);
free(ps->xinerama_scr_regs);
ps->xinerama_scr_regs = NULL;
}
ps->xinerama_nscrs = 0;
}