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