Page MenuHomeWildfire Games

Fix UB following rP22456

Authored by wraitii on Jul 14 2019, 10:48 AM.


Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
rP22470: Fix UB following rP22456, which could cause a crash when serialising.

I (wrongly) assumed in rP22456 that not giving a default value to the ticket's m_Type variable was fine since we always assigned it a value before actually using it (in RequestShort/LongPath), however I failed to anticipate that we might serialise before that gets called, and that then a garbage value in the enum could make serialisation fail.

This fixes it by giving the type a default value.

Reported by @gameboy, confirmed by @Angen, see

Test Plan

Save a game with some units that never moved and notice it doesn't crash on VS13 anymore (possibly also other systems - this is UB so potentially tricky to reproduce)

Diff Detail

rP 0 A.D. Public Repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wraitii created this revision.Jul 14 2019, 10:48 AM

Successful build - Chance fights ever on the side of the prudent.

Link to build:

Angen accepted this revision.Jul 14 2019, 11:09 AM

builds, saves, loads without error or crash

This revision is now accepted and ready to land.Jul 14 2019, 11:09 AM
This revision was automatically updated to reflect the committed changes.