From 853537d7813125fbd0a1e1167ab40ce5bc8b99eb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 3 May 2016 00:30:03 -0400 Subject: don't read uninit memory if the selection goes away --- libvt100 | 2 +- src/window-xlib.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libvt100 b/libvt100 index a9bb204..b09da58 160000 --- a/libvt100 +++ b/libvt100 @@ -1 +1 @@ -Subproject commit a9bb204743db4ea59c92144f47569d40c0789fb5 +Subproject commit b09da58557d35552cb1ddefa206012fafcbaa95f diff --git a/src/window-xlib.c b/src/window-xlib.c index 692029f..00f4545 100644 --- a/src/window-xlib.c +++ b/src/window-xlib.c @@ -902,11 +902,13 @@ static void runes_window_backend_handle_selection_request_event( } vt100_screen_get_string_plaintext(&t->scr, start, end, &contents, &len); - XChangeProperty( - w->dpy, e->requestor, e->property, - e->target, 8, PropModeReplace, - (unsigned char *)contents, len); - free(contents); + if (contents) { + XChangeProperty( + w->dpy, e->requestor, e->property, + e->target, 8, PropModeReplace, + (unsigned char *)contents, len); + free(contents); + } } else { selection.property = None; -- cgit v1.2.3