]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - unix/uxsel.c
first pass
[PuTTY.git] / unix / uxsel.c
index e2979c9a01e6aed34f27c5f2bf440bb5dd083717..ef25cdb574e2a6cf7fe4bb95112be1e05e52b947 100644 (file)
@@ -19,7 +19,7 @@ struct fd {
     int fd;
     int rwx;                          /* 4=except 2=write 1=read */
     uxsel_callback_fn callback;
-    int id;                           /* for uxsel_input_remove */
+    uxsel_id *id;                      /* for uxsel_input_remove */
 };
 
 static tree234 *fds;
@@ -64,6 +64,8 @@ void uxsel_set(int fd, int rwx, uxsel_callback_fn callback)
 {
     struct fd *newfd;
 
+    assert(fd >= 0);
+
     uxsel_del(fd);
 
     if (rwx) {
@@ -80,7 +82,8 @@ void uxsel_del(int fd)
 {
     struct fd *oldfd = find234(fds, &fd, uxsel_fd_findcmp);
     if (oldfd) {
-       uxsel_input_remove(oldfd->id);
+       if (oldfd->id)
+            uxsel_input_remove(oldfd->id);
        del234(fds, oldfd);
        sfree(oldfd);
     }