Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua: don't destroy keys during table iteration #10171

merged 2 commits into from Apr 9, 2021


Copy link

@Habbie Habbie commented Mar 11, 2021

via ahupowerdns/luawrapper#38

Short description

This avoids a dnsdist crash when code returns an array-shaped table (i.e. return {1,2,3}).


I have:

  • read the document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master

Copy link
Member Author

Habbie commented Mar 11, 2021

@cmouse thanks, your changes make sense - I'll upstream those first to go through the LuaWrapper testsuite.

Copy link

@omoerbeek omoerbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative I like a little better: (it has two pop calls which isn't very nice either):
But approved either way.

if (val != nullptr) {
  std::string result;
  result.assign(val, len);
  lua_pop(state, 1);
  return boost::optional<std::string>{ std::move(result) };
else {
  lua_pop(state, 1);
  return boost::none;

@Habbie Habbie merged commit 724e425 into PowerDNS:master Apr 9, 2021
@Habbie Habbie deleted the lua-array-next branch April 9, 2021 11:23
rgacogne added a commit to rgacogne/pdns that referenced this pull request Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants