Browse Source

made sure data (RRsetList) is initialized in each iteration of the while loop
in runQuery().

the bug is a perfect example of why we should define variables as locally as
possible (and more preferably why we should avoid using variables maintaining
states as much as possible in the first place)


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@715 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya 15 years ago
parent
commit
624f839fd3
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/lib/auth/cpp/data_source.cc

+ 2 - 1
src/lib/auth/cpp/data_source.cc

@@ -13,11 +13,11 @@ namespace dns {
 DSResult
 DataSrc::runQuery(Query q) {
     DSResult result;
-    RRsetList data, sigs;
     Name container(".");
     Message& m = q.message();
 
     while (!q.tasks().empty()) {
+        RRsetList data, sigs;
         bool found = false;
         QueryTaskPtr task = q.tasks().front();
         q.tasks().pop();
@@ -40,6 +40,7 @@ DataSrc::runQuery(Query q) {
 
         switch (result) {
             case SUCCESS:
+                // XXX: what if 'data' contains more than one RRset?
                 m.addRRset(task->section, data[0]);
                 if (q.wantDnssec() && sigs.size() == 1) {
                     m.addRRset(Section(task->section), sigs[0]);