-
Notifications
You must be signed in to change notification settings - Fork 0
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
Steam networking testing #1
Conversation
…ast 1 client it would crash on exit.
…eadless Engine usage
…wasn't working at all)
this project is making me depressed
} | ||
if (msgCount > 0) { | ||
for (int i = 0; i < msgCount; i++) { | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage)); |
Check failure
Code scanning / CodeQL
Suspicious add with sizeof High
ISteamNetworkingMessage *
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 10 days ago
To fix the problem, we need to remove the manual scaling by sizeof(ISteamNetworkingMessage)
in the pointer arithmetic expression. Instead of adding i * sizeof(ISteamNetworkingMessage)
to incomingMessages
, we should simply add i
to it. This will correctly compute the offset based on the size of ISteamNetworkingMessage
.
- Change the line where
incomingMessage
is calculated by removing the multiplication bysizeof(ISteamNetworkingMessage)
. - The file to edit is
src/engine.cpp
. - No additional methods, imports, or definitions are needed to implement this change.
-
Copy modified line R3114
@@ -3113,3 +3113,3 @@ | ||
for (int i = 0; i < msgCount; i++) { | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage)); | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + i; | ||
|
} | ||
if (msgCount > 0) { | ||
for (int i = 0; i < msgCount; i++) { | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage)); |
Check failure
Code scanning / CodeQL
Suspicious add with sizeof High
ISteamNetworkingMessage *
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 10 days ago
To fix the problem, we need to remove the manual scaling by sizeof(ISteamNetworkingMessage)
in the pointer arithmetic. Instead of using incomingMessages + (i * sizeof(ISteamNetworkingMessage))
, we should simply use incomingMessages + i
. This will correctly compute the address of the i
-th element in the array of ISteamNetworkingMessage
pointers.
-
Copy modified line R3234
@@ -3233,3 +3233,3 @@ | ||
for (int i = 0; i < msgCount; i++) { | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage)); | ||
ISteamNetworkingMessage *incomingMessage = incomingMessages + i; | ||
|
No description provided.