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