[ioquake3] 110/136: Don't use uninitialized ps from BotAI_GetClientState
Simon McVittie
smcv at debian.org
Thu Jun 15 09:09:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit 6e340f9a5b185b58b80063655cd4cffd463b707c
Author: Zack Middleton <zack at cloemail.com>
Date: Wed Jun 7 19:02:01 2017 -0500
Don't use uninitialized ps from BotAI_GetClientState
If BotAI_GetPlayerState returns qfalse, ps is untouched and in
some cases means uninitialized. So don't use it if not valid.
---
code/game/ai_chat.c | 12 ++++--------
code/game/ai_dmq3.c | 5 ++++-
code/game/ai_main.c | 6 ++++--
code/game/ai_team.c | 8 ++++++--
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/code/game/ai_chat.c b/code/game/ai_chat.c
index ecb0b9b..a65875f 100644
--- a/code/game/ai_chat.c
+++ b/code/game/ai_chat.c
@@ -100,8 +100,7 @@ int BotIsFirstInRankings(bot_state_t *bs) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
- BotAI_GetClientState(i, &ps);
- if (score < ps.persistant[PERS_SCORE]) return qfalse;
+ if (BotAI_GetClientState(i, &ps) && score < ps.persistant[PERS_SCORE]) return qfalse;
}
return qtrue;
}
@@ -124,8 +123,7 @@ int BotIsLastInRankings(bot_state_t *bs) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
- BotAI_GetClientState(i, &ps);
- if (score > ps.persistant[PERS_SCORE]) return qfalse;
+ if (BotAI_GetClientState(i, &ps) && score > ps.persistant[PERS_SCORE]) return qfalse;
}
return qtrue;
}
@@ -150,8 +148,7 @@ char *BotFirstClientInRankings(void) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
- BotAI_GetClientState(i, &ps);
- if (ps.persistant[PERS_SCORE] > bestscore) {
+ if (BotAI_GetClientState(i, &ps) && ps.persistant[PERS_SCORE] > bestscore) {
bestscore = ps.persistant[PERS_SCORE];
bestclient = i;
}
@@ -180,8 +177,7 @@ char *BotLastClientInRankings(void) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
- BotAI_GetClientState(i, &ps);
- if (ps.persistant[PERS_SCORE] < worstscore) {
+ if (BotAI_GetClientState(i, &ps) && ps.persistant[PERS_SCORE] < worstscore) {
worstscore = ps.persistant[PERS_SCORE];
bestclient = i;
}
diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c
index 6de1117..3cc61f2 100644
--- a/code/game/ai_dmq3.c
+++ b/code/game/ai_dmq3.c
@@ -206,7 +206,10 @@ qboolean EntityIsDead(aas_entityinfo_t *entinfo) {
if (entinfo->number >= 0 && entinfo->number < MAX_CLIENTS) {
//retrieve the current client state
- BotAI_GetClientState( entinfo->number, &ps );
+ if (!BotAI_GetClientState(entinfo->number, &ps)) {
+ return qfalse;
+ }
+
if (ps.pm_type != PM_NORMAL) return qtrue;
}
return qfalse;
diff --git a/code/game/ai_main.c b/code/game/ai_main.c
index a01e153..907a161 100644
--- a/code/game/ai_main.c
+++ b/code/game/ai_main.c
@@ -990,8 +990,10 @@ int BotAI(int client, float thinktime) {
}
//retrieve the current client state
- BotAI_GetClientState( client, &bs->cur_ps );
-
+ if (!BotAI_GetClientState(client, &bs->cur_ps)) {
+ BotAI_Print(PRT_FATAL, "BotAI: failed to get player state for player %d\n", client);
+ return qfalse;
+ }
//retrieve any waiting server commands
while( trap_BotGetServerCommand(client, buf, sizeof(buf)) ) {
//have buf point to the command and args to the command arguments
diff --git a/code/game/ai_team.c b/code/game/ai_team.c
index 6176bd5..95b445c 100644
--- a/code/game/ai_team.c
+++ b/code/game/ai_team.c
@@ -108,8 +108,12 @@ int BotClientTravelTimeToGoal(int client, bot_goal_t *goal) {
playerState_t ps;
int areanum;
- BotAI_GetClientState(client, &ps);
- areanum = BotPointAreaNum(ps.origin);
+ if (BotAI_GetClientState(client, &ps)) {
+ areanum = BotPointAreaNum(ps.origin);
+ } else {
+ areanum = 0;
+ }
+
if (!areanum) return 1;
return trap_AAS_AreaTravelTimeToGoalArea(areanum, ps.origin, goal->areanum, TFL_DEFAULT);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list