Commit Diff


commit - 7c7d7bb779eb716b43704a3e5c77590e2b823edd
commit + 15354eed0814392f42d04f3b6aeb71df253b1d66
blob - af43095fcb1ef93bf6db6aa1eda811e2a14ef1ef
blob + 437e23e1a780902fc071dc50f6ebe40869eab779
--- gemini.c
+++ gemini.c
@@ -52,6 +52,7 @@ static int 		 conn_towards(struct url*, char**);
 
 static void		 close_with_err(struct req*, const char *err);
 static struct req	*req_by_id(uint32_t);
+static struct req	*req_by_id_try(uint32_t);
 
 static void		 do_handshake(int, short, void*);
 static void		 write_request(int, short, void*);
@@ -176,6 +177,16 @@ conn_towards(struct url *url, char **err)
 
 static struct req *
 req_by_id(uint32_t id)
+{
+	struct req *r;
+
+	if ((r = req_by_id_try(id)) == NULL)
+		die();
+	return r;
+}
+
+static struct req *
+req_by_id_try(uint32_t id)
 {
 	struct req *r;
 
@@ -184,7 +195,7 @@ req_by_id(uint32_t id)
 			return r;
 	}
 
-	die();
+	return NULL;
 }
 
 static void
@@ -468,7 +479,8 @@ handle_stop(struct imsg *imsg, size_t datalen)
 {
 	struct req	*req;
 
-	req = req_by_id(imsg->hdr.peerid);
+	if ((req = req_by_id_try(imsg->hdr.peerid)) == NULL)
+		return;
 	close_conn(0, 0, req);
 }