Skip to content

Fix unit test use after return#16831

Open
cx384 wants to merge 1 commit intoluanti-org:masterfrom
cx384:unit_test_use_after_return
Open

Fix unit test use after return#16831
cx384 wants to merge 1 commit intoluanti-org:masterfrom
cx384:unit_test_use_after_return

Conversation

@cx384
Copy link
Member

@cx384 cx384 commented Jan 9, 2026

Fixes a use after return, when using the MockGameDef.

It's not a beautiful solution, but I suppose we don't want to define any copy (or move) constructors for the content features struct, and we want to keep the visuals pointer inside the content features and reverse.

To do

Ready for Review.

How to test

Compile with address sanitizers
Execute unittests

@cx384 cx384 added Bugfix 🐛 PRs that fix a bug Unit tests labels Jan 9, 2026
m_content_features[id] = def;

#if CHECK_CLIENT_BUILD()
// Fix copy
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking def.visuals should rather be guaranteed nullptr when set() is called.
and the test code should be re-worked to work like the real code (set everything first, update visuals afterwards)

@cx384 cx384 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Action / change needed Code still needs changes (PR) / more information requested (Issues) Bugfix 🐛 PRs that fix a bug Unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants