X11 : fix crash in Handle_SelectionNotify() when Clipboard cannot be converted to UTF8_STRING

This commit is contained in:
Thomas Bernard 2018-12-29 15:57:27 +01:00
parent 75210cfe7c
commit a68343d2ad
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -478,6 +478,12 @@ static int Handle_SelectionNotify(const XSelectionEvent* xselection)
unsigned long count = 0, bytesAfter = 0; unsigned long count = 0, bytesAfter = 0;
unsigned char * value = NULL; unsigned char * value = NULL;
GFX2_Log(GFX2_DEBUG, "xselection: selection=%s property=%s target=%s\n",
XGetAtomName(X11_display, xselection->selection),
xselection->property == None ? "None" : XGetAtomName(X11_display, xselection->property),
XGetAtomName(X11_display, xselection->target));
if (xselection->property != None)
{
r = XGetWindowProperty(X11_display, X11_window, xselection->property, 0, LONG_MAX, r = XGetWindowProperty(X11_display, X11_window, xselection->property, 0, LONG_MAX,
False, xselection->target /* type */, &type, &format, False, xselection->target /* type */, &type, &format,
&count, &bytesAfter, &value); &count, &bytesAfter, &value);
@ -489,6 +495,11 @@ static int Handle_SelectionNotify(const XSelectionEvent* xselection)
user_feedback_required = 1; user_feedback_required = 1;
} }
else else
{
GFX2_Log(GFX2_INFO, "X11 Selection conversion failed\n");
}
}
else
{ {
GFX2_Log(GFX2_INFO, "Unhandled SelectNotify selection=%s\n", XGetAtomName(X11_display, xselection->selection)); GFX2_Log(GFX2_INFO, "Unhandled SelectNotify selection=%s\n", XGetAtomName(X11_display, xselection->selection));
} }