check for empty X11 clipboard data

This commit is contained in:
Thomas Bernard 2019-02-15 13:09:36 +01:00
parent 22a895f45c
commit a808eaa9bb
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -536,14 +536,17 @@ static int Handle_SelectionNotify(const XSelectionEvent* xselection)
GFX2_Log(GFX2_DEBUG, "Clipboard value=%p %lu bytes format=%d type=%s\n", GFX2_Log(GFX2_DEBUG, "Clipboard value=%p %lu bytes format=%d type=%s\n",
value, count, format, type_name); value, count, format, type_name);
XFree(type_name); XFree(type_name);
X11_clipboard_size = count; if (count > 0)
if (xselection->target == XInternAtom(X11_display, "UTF8_STRING", False)) {
X11_clipboard = strdup((char *)value); // Text Clipboard X11_clipboard_size = count;
else if (xselection->target == XInternAtom(X11_display, "image/png", False)) if (xselection->target == XInternAtom(X11_display, "UTF8_STRING", False))
{ // Picture clipboard (PNG) X11_clipboard = strdup((char *)value); // Text Clipboard
X11_clipboard = malloc(count); else if (xselection->target == XInternAtom(X11_display, "image/png", False))
if (X11_clipboard != NULL) { // Picture clipboard (PNG)
memcpy(X11_clipboard, value, count); X11_clipboard = malloc(count);
if (X11_clipboard != NULL)
memcpy(X11_clipboard, value, count);
}
} }
XFree(value); XFree(value);
} }