Commit 704ac5a5 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Added an error handler to catch bad atoms in clipboard selections.

parent 10629e23
...@@ -1728,6 +1728,11 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec ...@@ -1728,6 +1728,11 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec
} }
static int is_atom_error( Display *display, XErrorEvent *event, void *arg )
{
return (event->error_code == BadAtom);
}
/************************************************************************** /**************************************************************************
* X11DRV_CLIPBOARD_InsertSelectionProperties * X11DRV_CLIPBOARD_InsertSelectionProperties
* *
...@@ -1759,7 +1764,7 @@ static VOID X11DRV_CLIPBOARD_InsertSelectionProperties(Display *display, Atom* p ...@@ -1759,7 +1764,7 @@ static VOID X11DRV_CLIPBOARD_InsertSelectionProperties(Display *display, Atom* p
lpFormat = X11DRV_CLIPBOARD_LookupProperty(lpFormat, properties[i]); lpFormat = X11DRV_CLIPBOARD_LookupProperty(lpFormat, properties[i]);
} }
} }
else else if (properties[i])
{ {
/* add it to the list of atoms that we don't know about yet */ /* add it to the list of atoms that we don't know about yet */
if (!atoms) atoms = HeapAlloc( GetProcessHeap(), 0, if (!atoms) atoms = HeapAlloc( GetProcessHeap(), 0,
...@@ -1774,13 +1779,13 @@ static VOID X11DRV_CLIPBOARD_InsertSelectionProperties(Display *display, Atom* p ...@@ -1774,13 +1779,13 @@ static VOID X11DRV_CLIPBOARD_InsertSelectionProperties(Display *display, Atom* p
char **names = HeapAlloc( GetProcessHeap(), 0, nb_atoms * sizeof(*names) ); char **names = HeapAlloc( GetProcessHeap(), 0, nb_atoms * sizeof(*names) );
if (names) if (names)
{ {
wine_tsx11_lock(); X11DRV_expect_error( display, is_atom_error, NULL );
/* FIXME: we're at the mercy of the app sending the event here. if (!XGetAtomNames( display, atoms, nb_atoms, names )) nb_atoms = 0;
* Currently if they send a bogus atom, we will crash. if (X11DRV_check_error())
* We should handle BadAtom errors gracefully in this call. {
*/ WARN( "got some bad atoms, ignoring\n" );
XGetAtomNames( display, atoms, nb_atoms, names ); nb_atoms = 0;
wine_tsx11_unlock(); }
for (i = 0; i < nb_atoms; i++) for (i = 0; i < nb_atoms; i++)
{ {
WINE_CLIPFORMAT *lpFormat; WINE_CLIPFORMAT *lpFormat;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment