Index: lib/Mail/SpamAssassin/DnsResolver.pm
===================================================================
--- lib/Mail/SpamAssassin/DnsResolver.pm	(revision 1790937)
+++ lib/Mail/SpamAssassin/DnsResolver.pm	(working copy)
@@ -581,7 +581,7 @@
     #    time, $domain, $type, $packet->id);
     1;
   } or do {
-    # this can if a domain name in a query is invalid, or if a timeout signal
+    # get here if a domain name in a query is invalid, or if a timeout signal
     # happened to be trapped by this eval, or if Net::DNS signalled an error
     my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
     # resignal if alarm went off
@@ -674,7 +674,7 @@
 
   my $id = $self->{resolver}->bgsend($domain, $type, undef, sub {
         my ($reply, $reply_id, $timestamp) = @_;
-        $self->got_a_reply ($reply, $reply_id);
+        $self->got_a_reply($reply, $reply_id);
       });
 
 The callback can ignore the reply as an invalid packet sent to the listening
@@ -747,7 +747,8 @@
   my($answerpkt, $decoded_length) = Net::DNS::Packet->new(\$data);
   $answerpkt or die "bgread: decoding DNS packet failed: $@";
   $answerpkt->answerfrom($peerhost);
-  if ($decoded_length ne length($data)) {
+  $decoded_length ||= 0;
+  if ($decoded_length != length($data)) {
     warn sprintf("bgread: received a %d bytes packet from %s, decoded %d bytes\n",
                  length($data), $peerhost, $decoded_length);
   }
@@ -804,8 +805,10 @@
     last  if $nfound == 0;
 
     my $packet;
+    # Bug 7265, use our own bgread() below
+    # $packet = $self->{res}->bgread($self->{sock});
     eval {
-      $packet = $self->bgread();
+      $packet = $self->bgread();  # Bug 7265, use our own bgread()
     } or do {
       undef $packet;
       my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
@@ -814,9 +817,6 @@
       info("dns: bad dns reply: %s", $eval_stat);
     };
 
-#   Bug 7265, use our own bgread()
-#   my $packet = $self->{res}->bgread($self->{sock});
-
     if (!$packet) {
       # error already reported above
 #     my $dns_err = $self->{res}->errorstring;
