]> granicus.if.org Git - pdns/commitdiff
getAction(n) for n >= number of rules now properly returns nil instead of crashing
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 26 Apr 2016 11:35:06 +0000 (13:35 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 26 Apr 2016 11:35:06 +0000 (13:35 +0200)
pdns/dnsdist-lua2.cc

index c21fe1899c0bbd92c559d3385d00def37206f045..cb641be16809cabd8048bf19e1a8275fbd709813 100644 (file)
@@ -602,10 +602,11 @@ void moreLua(bool client)
 
     g_lua.writeFunction("getAction", [](unsigned int num) {
         setLuaNoSideEffect();
+        boost::optional<std::shared_ptr<DNSAction>> ret;
         auto rulactions = g_rulactions.getCopy();
-        if(num >= rulactions.size())
-          return std::shared_ptr<DNSAction>();
-        return rulactions[num].second;
+        if(num < rulactions.size())
+          ret=rulactions[num].second;
+        return ret;
       });
 
     g_lua.registerFunction("getStats", &DNSAction::getStats);