Index: trunk/pdns/pdns/packethandler.cc
===================================================================
--- trunk/pdns/pdns/packethandler.cc	(revision 167)
+++ trunk/pdns/pdns/packethandler.cc	(revision 172)
@@ -155,5 +155,5 @@
 
   if (p->qclass == 3 && p->qtype.getName() == "HINFO") {
-    rr.content = "PowerDNS $Id: packethandler.cc,v 1.14 2003/04/05 19:31:52 ahu Exp $";
+    rr.content = "PowerDNS $Id: packethandler.cc,v 1.15 2003/05/24 16:02:47 ahu Exp $";
     rr.ttl = 5;
     rr.qname=target;
@@ -171,5 +171,5 @@
   DNSResourceRecord rr;
   if(p->qtype.getCode()==QType::TXT && target=="version.bind") {// TXT
-    rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.14 2003/04/05 19:31:52 ahu Exp $";
+    rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.15 2003/05/24 16:02:47 ahu Exp $";
     rr.ttl=5;
     rr.qname=target;
@@ -305,11 +305,19 @@
 
     vector<DNSResourceRecord *> arrs=r->getAPRecords();
+    vector<DNSResourceRecord> crrs;
+
     for(vector<DNSResourceRecord *>::const_iterator i=arrs.begin();
-	i!=arrs.end();
+	i!=arrs.end();	++i) 
+      crrs.push_back(**i);
+
+    // we now have a copy, push_back on packet might reallocate!
+
+    for(vector<DNSResourceRecord>::const_iterator i=crrs.begin();
+	i!=crrs.end();
 	++i) {
       
-      if((*i)->qtype.getCode()==QType::NS && !B.getSOA((*i)->qname,sd)) { // drop AA in case of non-SOA-level NS answer
+      if(i->qtype.getCode()==QType::NS && !B.getSOA(i->qname,sd)) { // drop AA in case of non-SOA-level NS answer
 	r->d.aa=false;
-	(*i)->d_place=DNSResourceRecord::AUTHORITY;
+	//	i->d_place=DNSResourceRecord::AUTHORITY; // XXX FIXME
       }
 
@@ -317,10 +325,10 @@
       qtypes[0]="A"; qtypes[1]="AAAA";
       for(int n=0;n < d_doIPv6AdditionalProcessing + 1; ++n) {
-	B.lookup(qtypes[n],(*i)->content,p);  
+	B.lookup(qtypes[n],i->content,p);  
 	bool foundOne=false;
 	while(B.get(rr)) {
 	  foundOne=true;
-	  if(rr.domain_id!=(*i)->domain_id && arg()["out-of-zone-additional-processing"]=="no") {
-	    DLOG(L<<Logger::Warning<<"Not including out-of-zone additional processing of "<<(*i)->qname<<" ("<<rr.qname<<")"<<endl);
+	  if(rr.domain_id!=i->domain_id && arg()["out-of-zone-additional-processing"]=="no") {
+	    DLOG(L<<Logger::Warning<<"Not including out-of-zone additional processing of "<<i->qname<<" ("<<rr.qname<<")"<<endl);
 	    continue; // not adding out-of-zone additional data
 	  }
@@ -334,5 +342,5 @@
 	    try {
 	      Resolver resolver;
-	      resolver.resolve(arg()["recursor"],(*i)->content.c_str(),QType::A);
+	      resolver.resolve(arg()["recursor"],i->content.c_str(),QType::A);
 	      Resolver::res_t res=resolver.result();
 	      for(Resolver::res_t::const_iterator j=res.begin();j!=res.end();++j) {
@@ -794,4 +802,7 @@
     
 
+    
+    
+
     r->wrapup(); // needed for inserting in cache
     PC.insert(p,r); // in the packet cache
