fix(clipboard): handle bad write to pipe fd

This commit is contained in:
Jeremy Attali 2020-01-05 22:44:10 -05:00
parent 6a598cb4c8
commit f963a76c5c

View File

@ -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);