dix: Clear any existing selections before initializing privates
authorAndrew Eikum <aeikum@codeweavers.com>
Mon, 30 Dec 2013 15:15:41 +0000 (09:15 -0600)
committerKeith Packard <keithp@keithp.com>
Fri, 7 Mar 2014 01:15:11 +0000 (17:15 -0800)
commit78e508c9379b3976ac8e76b7aaa90ba86ad4e443
tree82bc35047ff6dc0aa43f6793708dee496f036e43
parentda08316605b26830b4d8f8fb2d9e69471cdc80ab
dix: Clear any existing selections before initializing privates

If there is a selection left over from a previous execution of the
main loop, and that selection has privates allocated for it, the X
server will crash. This is because dixResetPrivates() resets the
privates refcounts to zero without accounting for the reference held
by the selection object. When the selection is then deleted in
InitSelections() after the call to dixResetPrivates(), the refcount
for its privates type goes negative and bad things happen.

To fix this, we should delete any existing selections before calling
dixResetPrivates(). This will properly release the selection's
privates and avoid the crash.

A more thorough description of the problem and a test case to
reproduce the crash is available at a previous mail:
  "Negative Selection devPrivates refcount?"
  By Andrew Eikum to xorg-devel on 10 Dec 2013
  http://lists.freedesktop.org/archives/xorg-devel/2013-December/039492.html

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
dix/main.c