Skip to content

Commit

Permalink
core: fix rare double-free when xinerama update fails
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tryone144 committed Aug 4, 2021
1 parent 24b4450 commit 78e8666
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 78e8666

Please sign in to comment.