-
Notifications
You must be signed in to change notification settings - Fork 213
fix(network): Fix missing value initialization of LANGameInfo::m_isDirectConnect #1836
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,8 @@ LANGameInfo::LANGameInfo() | |
| { | ||
| m_lastHeard = 0; | ||
| m_next = NULL; | ||
| m_isDirectConnect = false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you certain this caused uninitialized memory use on runtime? LANGameInfo is allocated through Game Memory overloads, which means its memory is memset 0 before the constructor is called. So if you look at this object in debugger, then this field should 0 regardless.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I think you're right here. Is it still good practice to do it explicitly here? If not, I can just drop that commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happens all over the code base. Class members are not explicitly zero initialized, which is a mistake in principle, but the memory allocator is forgiving (and very pessimistic) by zeroing every allocation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I don't think this changed anything, but it's always a good idea to initialize variables. The meaningful change is setting |
||
| // | ||
| for (Int i = 0; i< MAX_SLOTS; ++i) | ||
| setSlotPointer(i, &m_LANSlot[i]); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What issue did this cause then? Was Direct Connect game visible in Network Lobby when it should not have been?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have my PC to check this, I was just following the notes in the Issue.
handleRequestLocationshandler wasn't settingreply.GameInfo.isDirectConnectwhen building the game announcement message, so could we end up sending uninitialized data in that specific message struct? Does LANMessage reply also get auto zeroed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to test the consequence of this bug so we can properly describe what this change fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comments on this PR.