Skip to content

Conversation

@jprzimba
Copy link
Collaborator

Potential Memory Leak

  • The function used lua_error(L) mid-execution. If the Lua/C++ environment is not configured to unwind the C++ stack during a Lua error (which uses longjmp), the destructors of the local objects (std::shared_ptr<MonsterType>, std::set, std::string) would not be called.
  • This would cause a leak of the memory allocated for MonsterType and for the strings/sets.

Inconsistent State

  • The code attempted to register multiple names (original name, variant, alternative name) in a loop.
  • If the first name was successfully registered, but the second failed (already existing), the code called lua_error.

The result would be a "half-registered" monster in the system, but the Lua script would receive an error and stop, leaving the server in a dirty state.

@gabrielew
Copy link
Contributor

using in production for a week

@jprzimba
Copy link
Collaborator Author

jprzimba commented Dec 31, 2025

using in production for a week

Thank you for your feedback

Copy link

@QuebradaZN QuebradaZN left a comment

Choose a reason for hiding this comment

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

working without problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants