]> granicus.if.org Git - pdns/commitdiff
Merge pull request #4758 from rgacogne/rec-dq-on-stack
authorRemi Gacogne <rgacogne@users.noreply.github.com>
Tue, 20 Dec 2016 08:45:23 +0000 (09:45 +0100)
committerGitHub <noreply@github.com>
Tue, 20 Dec 2016 08:45:23 +0000 (09:45 +0100)
rec: Allocate the DNSQuestion `dq` object on the stack

1  2 
pdns/pdns_recursor.cc

index 7bcbbbfa447bbccb83b52622cd7998d42fc5d917,08ee4d101dc50343116f559f69eca2badcee2079..9608e298ba83d004cbc4b131b5ef81938a85536d
@@@ -760,22 -740,18 +760,19 @@@ void startDoResolve(void *p
      bool variableAnswer = false;
      bool shouldNotValidate = false;
  
 -    int res;
 +    /* preresolve expects res (dq.rcode) to be set to RCode::NoError by default */
 +    int res = RCode::NoError;
      DNSFilterEngine::Policy appliedPolicy;
      DNSRecord spoofed;
-     std::shared_ptr<RecursorLua4::DNSQuestion> dq = nullptr;
-     if (t_pdl->get() && (*t_pdl)->needDQ()) {
-       dq = std::make_shared<RecursorLua4::DNSQuestion>(dc->d_remote, dc->d_local, dc->d_mdp.d_qname, dc->d_mdp.d_qtype, dc->d_tcp, variableAnswer, wantsRPZ);
-       dq->ednsFlags = &edo.d_Z;
-       dq->ednsOptions = &dc->d_ednsOpts;
-       dq->tag = dc->d_tag;
-       dq->discardedPolicies = &sr.d_discardedPolicies;
-       dq->policyTags = &dc->d_policyTags;
-       dq->appliedPolicy = &appliedPolicy;
-       dq->currentRecords = &ret;
-       dq->dh = &dc->d_mdp.d_header;
-     }
+     RecursorLua4::DNSQuestion dq(dc->d_remote, dc->d_local, dc->d_mdp.d_qname, dc->d_mdp.d_qtype, dc->d_tcp, variableAnswer, wantsRPZ);
+     dq.ednsFlags = &edo.d_Z;
+     dq.ednsOptions = &dc->d_ednsOpts;
+     dq.tag = dc->d_tag;
+     dq.discardedPolicies = &sr.d_discardedPolicies;
+     dq.policyTags = &dc->d_policyTags;
+     dq.appliedPolicy = &appliedPolicy;
+     dq.currentRecords = &ret;
+     dq.dh = &dc->d_mdp.d_header;
  
      if(dc->d_mdp.d_qtype==QType::ANY && !dc->d_tcp && g_anyToTcp) {
        pw.getHeader()->tc = 1;