Skip to content

Commit 818680e

Browse files
authored
[GEN][ZH] Fix dereferencing NULL pointer 'hostStruct' in PingThreadClass::Thread_Function() (#1102)
1 parent 6026f2c commit 818680e

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,12 @@ void GameResultsThreadClass::Thread_Function()
265265
// callback.
266266
IP = 0xFFFFFFFF; // flag for IP resolve failed
267267
}
268-
hostNode = (in_addr *) hostStruct->h_addr;
269-
IP = hostNode->s_addr;
270-
DEBUG_LOG(("sending game results to %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
268+
else
269+
{
270+
hostNode = (in_addr *) hostStruct->h_addr;
271+
IP = hostNode->s_addr;
272+
DEBUG_LOG(("sending game results to %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
273+
}
271274
}
272275

273276
int result = sendGameResults( IP, req.port, req.results );

Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,12 @@ void PingThreadClass::Thread_Function()
285285
// callback.
286286
IP = 0xFFFFFFFF; // flag for IP resolve failed
287287
}
288-
hostNode = (in_addr *) hostStruct->h_addr;
289-
IP = hostNode->s_addr;
290-
DEBUG_LOG(("pinging %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
288+
else
289+
{
290+
hostNode = (in_addr *) hostStruct->h_addr;
291+
IP = hostNode->s_addr;
292+
DEBUG_LOG(("pinging %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
293+
}
291294
}
292295

293296
// do ping

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,12 @@ void GameResultsThreadClass::Thread_Function()
247247
// callback.
248248
IP = 0xFFFFFFFF; // flag for IP resolve failed
249249
}
250-
hostNode = (in_addr *) hostStruct->h_addr;
251-
IP = hostNode->s_addr;
252-
DEBUG_LOG(("sending game results to %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
250+
else
251+
{
252+
hostNode = (in_addr *) hostStruct->h_addr;
253+
IP = hostNode->s_addr;
254+
DEBUG_LOG(("sending game results to %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
255+
}
253256
}
254257

255258
int result = sendGameResults( IP, req.port, req.results );

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,12 @@ void PingThreadClass::Thread_Function()
285285
// callback.
286286
IP = 0xFFFFFFFF; // flag for IP resolve failed
287287
}
288-
hostNode = (in_addr *) hostStruct->h_addr;
289-
IP = hostNode->s_addr;
290-
DEBUG_LOG(("pinging %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
288+
else
289+
{
290+
hostNode = (in_addr *) hostStruct->h_addr;
291+
IP = hostNode->s_addr;
292+
DEBUG_LOG(("pinging %s IP = %s\n", hostnameBuffer, inet_ntoa(*hostNode) ));
293+
}
291294
}
292295

293296
// do ping

0 commit comments

Comments
 (0)