From f963a76c5c01b9b5f81b97118bf1b9e6990d995d Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Sun, 5 Jan 2020 22:44:10 -0500 Subject: [PATCH] fix(clipboard): handle bad write to pipe fd --- src/clipboard.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/clipboard.c b/src/clipboard.c index f5e82d6..e1394b7 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -14,6 +14,7 @@ static gboolean send_pixbuf_to_wl_copy(gdk_pixbuf_t *pixbuf) { pid_t clipboard_process = 0; int pipefd[2]; int status; + ssize_t written; gsize size; gchar *buffer = NULL; GError *error = NULL; @@ -47,7 +48,13 @@ static gboolean send_pixbuf_to_wl_copy(gdk_pixbuf_t *pixbuf) { return false; } - write(pipefd[1], buffer, size); + written = write(pipefd[1], buffer, size); + if (written == -1) { + g_warning("unable to write to pipe fd for copy"); + g_free(buffer); + return false; + } + close(pipefd[1]); g_free(buffer); waitpid(clipboard_process, &status, 0);