mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Bug fix: Double free when XQueryTree() fails
Take care of failure of XQueryTree() to prevent it from causing a double-free crash. This usually happens when X is initializing and windows are constantly changing.
This commit is contained in:
parent
35f7d45130
commit
6f079af2f0
1 changed files with 24 additions and 6 deletions
|
@ -1022,7 +1022,7 @@ paint_all(Display *dpy, XserverRegion region) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_REPAINT
|
#ifdef DEBUG_REPAINT
|
||||||
printf(" 0x%x", w->id);
|
printf(" %#010lx", w->id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (clip_changed) {
|
if (clip_changed) {
|
||||||
|
@ -1418,8 +1418,17 @@ map_win(Display *dpy, Window id,
|
||||||
Window *tchildren;
|
Window *tchildren;
|
||||||
unsigned tnchildren;
|
unsigned tnchildren;
|
||||||
|
|
||||||
XQueryTree(dpy, wid, &troot, &parent, &tchildren, &tnchildren);
|
// XQueryTree probably fails if you run compton when X is somehow
|
||||||
XFree(tchildren);
|
// initializing (like add it in .xinitrc). In this case
|
||||||
|
// just leave it alone.
|
||||||
|
if(!XQueryTree(dpy, wid, &troot, &parent, &tchildren,
|
||||||
|
&tnchildren)) {
|
||||||
|
wid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tchildren)
|
||||||
|
XFree(tchildren);
|
||||||
wid = parent;
|
wid = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2934,11 +2943,20 @@ main(int argc, char **argv) {
|
||||||
&& !array_wid_exists(children, nchildren, wid)) {
|
&& !array_wid_exists(children, nchildren, wid)) {
|
||||||
Window troot;
|
Window troot;
|
||||||
Window parent;
|
Window parent;
|
||||||
Window *tchildren;
|
Window *tchildren = 0;
|
||||||
unsigned tnchildren;
|
unsigned tnchildren;
|
||||||
|
|
||||||
XQueryTree(dpy, wid, &troot, &parent, &tchildren, &tnchildren);
|
// XQueryTree probably fails if you run compton when X is somehow
|
||||||
XFree(tchildren);
|
// initializing (like add it in .xinitrc). In this case
|
||||||
|
// just leave it alone.
|
||||||
|
if(!XQueryTree(dpy, wid, &troot, &parent, &tchildren,
|
||||||
|
&tnchildren)) {
|
||||||
|
wid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tchildren)
|
||||||
|
XFree(tchildren);
|
||||||
wid = parent;
|
wid = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue