bc5dde
diff -up bind-9.5.0-P2/bin/dig/dighost.c.rh452060 bind-9.5.0-P2/bin/dig/dighost.c
bc5dde
--- bind-9.5.0-P2/bin/dig/dighost.c.rh452060	2008-12-01 22:30:01.000000000 +0100
bc5dde
+++ bind-9.5.0-P2/bin/dig/dighost.c	2008-12-01 22:30:07.000000000 +0100
bc5dde
@@ -1280,6 +1280,12 @@ clear_query(dig_query_t *query) {
bc5dde
 
bc5dde
 	debug("clear_query(%p)", query);
bc5dde
 
bc5dde
+	if (query->waiting_senddone) {
bc5dde
+		debug("send_done not yet called");
bc5dde
+		query->pending_free = ISC_TRUE;
bc5dde
+		return;
bc5dde
+	}
bc5dde
+
bc5dde
 	lookup = query->lookup;
bc5dde
 
bc5dde
 	if (lookup->current_query == query)
bc5dde
@@ -1301,10 +1307,7 @@ clear_query(dig_query_t *query) {
bc5dde
 	isc_mempool_put(commctx, query->recvspace);
bc5dde
 	isc_buffer_invalidate(&query->recvbuf);
bc5dde
 	isc_buffer_invalidate(&query->lengthbuf);
bc5dde
-	if (query->waiting_senddone)
bc5dde
-		query->pending_free = ISC_TRUE;
bc5dde
-	else
bc5dde
-		isc_mem_free(mctx, query);
bc5dde
+	isc_mem_free(mctx, query);
bc5dde
 }
bc5dde
 
bc5dde
 /*%
bc5dde
@@ -2175,9 +2178,9 @@ send_done(isc_task_t *_task, isc_event_t
bc5dde
 	isc_event_free(&event);
bc5dde
 
bc5dde
 	if (query->pending_free)
bc5dde
-		isc_mem_free(mctx, query);
bc5dde
+		clear_query(query);
bc5dde
 
bc5dde
-	check_if_done();
bc5dde
+	check_next_lookup(l);
bc5dde
 	UNLOCK_LOOKUP;
bc5dde
 }
bc5dde