Skip to content

Commit

Permalink
fix(clipboard): handle bad write to pipe fd
Browse files Browse the repository at this point in the history
  • Loading branch information
jtheoof committed Jan 6, 2020
1 parent 6a598cb commit f963a76
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f963a76

Please sign in to comment.