commit - 52b1043cbe49b88c7dc8b0baa3bb374206a59dd1
commit + 5d6c2088a3eb3f06195f5ac576f9c4fd673fae3b
blob - 521e743886854c1cb162a20563cd4a7dfabc322f
blob + 64512510844f0c1de085546ef2e52d3731b501b2
--- telescope.c
+++ telescope.c
}
static struct tab *
-tab_by_id(uint32_t id)
+tab_by_id_try(uint32_t id)
{
struct tab *t;
return t;
}
- die();
+ return NULL;
}
+static struct tab *
+tab_by_id(uint32_t id)
+{
+ struct tab *t;
+
+ if ((t = tab_by_id_try(id)) == NULL)
+ die();
+ return t;
+}
+
static void
handle_imsg_err(struct imsg *imsg, size_t datalen)
{
int l;
char *page, buf[FMT_SCALED_STRSIZE] = {0};
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL) {
+ /*
+ * Since messages between ui and net are asynchronous,
+ * we could be in a case where we sent a tab_stop
+ * command, but still receive data for the old id. My
+ * initial idea of crashing on invalid tab ids just
+ * doesn't scale well in an asynchronous world.
+ */
+ return;
+ }
tab->bytes += datalen;
if (tab->fd == -1) {