Page MenuHomeWildfire Games

Fix UB following rP22456
ClosedPublic

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

Details

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

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 https://code.wildfiregames.com/D1907#86396

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

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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: https://jenkins.wildfiregames.com/job/docker-differential/72/display/redirect

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.