diff --git a/code/botlib/be_aas_reach.c b/code/botlib/be_aas_reach.c index e23083e3..379948aa 100644 --- a/code/botlib/be_aas_reach.c +++ b/code/botlib/be_aas_reach.c @@ -2108,7 +2108,7 @@ int AAS_Reachability_Jump(int area1num, int area2num) int stopevent, areas[10], numareas; float phys_jumpvel, maxjumpdistance, maxjumpheight, height, bestdist, speed; vec_t *v1, *v2, *v3, *v4; - vec3_t beststart, beststart2 = {0}, bestend, bestend2 = {0}; + vec3_t beststart = {0}, beststart2 = {0}, bestend = {0}, bestend2 = {0}; vec3_t teststart, testend, dir, velocity, cmdmove, up = {0, 0, 1}, sidewards; aas_area_t *area1, *area2; aas_face_t *face1, *face2; @@ -3152,7 +3152,7 @@ aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoint int facenum, edgenum, bestfacenum; float *v1, *v2, *v3, *v4; float bestdist, speed, hordist, dist; - vec3_t beststart, beststart2 = {0}, bestend, bestend2 = {0}, tmp, hordir, testpoint; + vec3_t beststart = {0}, beststart2 = {0}, bestend = {0}, bestend2 = {0}, tmp, hordir, testpoint; aas_lreachability_t *lreach, *lreachabilities; aas_area_t *area; aas_face_t *face; diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c index a98213a4..e0438e89 100644 --- a/code/botlib/l_precomp.c +++ b/code/botlib/l_precomp.c @@ -2086,9 +2086,12 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval //remove the second value if not question mark operator if (o->operator != P_QUESTIONMARK) v = v->next; // - if (v->prev) v->prev->next = v->next; - else firstvalue = v->next; - if (v->next) v->next->prev = v->prev; + if (v) + { + if (v->prev) v->prev->next = v->next; + else firstvalue = v->next; + if (v->next) v->next->prev = v->prev; + } //FreeMemory(v); FreeValue(v); } //end if diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index b0b78066..f0dfcaca 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -1487,7 +1487,7 @@ EasyClientName char *EasyClientName(int client, char *buf, int size) { int i; char *str1, *str2, *ptr, c; - char name[128]; + char name[128] = {0}; ClientName(client, name, sizeof(name)); diff --git a/code/game/ai_team.c b/code/game/ai_team.c index 93e7af5d..2077eff8 100644 --- a/code/game/ai_team.c +++ b/code/game/ai_team.c @@ -1757,7 +1757,7 @@ BotHarvesterOrders */ void BotHarvesterOrders(bot_state_t *bs) { int numteammates, defenders, attackers, i; - int teammates[MAX_CLIENTS]; + int teammates[MAX_CLIENTS] = {0}; char name[MAX_NETNAME]; //sort team mates by travel time to base diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c index 9a271098..41594096 100644 --- a/code/game/bg_misc.c +++ b/code/game/bg_misc.c @@ -1087,7 +1087,6 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play // don't pick up if already at max #ifdef MISSIONPACK if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) { - upperBound = ps->stats[STAT_MAX_HEALTH]; } else #endif diff --git a/code/game/g_items.c b/code/game/g_items.c index 3e36e382..da8b7a8a 100644 --- a/code/game/g_items.c +++ b/code/game/g_items.c @@ -348,6 +348,10 @@ RespawnItem =============== */ void RespawnItem( gentity_t *ent ) { + if (!ent) { + return; + } + // randomly select from teamed entities if (ent->team) { gentity_t *master; diff --git a/code/game/g_mover.c b/code/game/g_mover.c index b7948777..756c0dd0 100644 --- a/code/game/g_mover.c +++ b/code/game/g_mover.c @@ -881,6 +881,10 @@ void Think_SpawnNewDoorTrigger( gentity_t *ent ) { vec3_t mins, maxs; int i, best; + if (!ent) { + return; + } + // set all of the slaves as shootable for ( other = ent ; other ; other = other->teamchain ) { other->takedamage = qtrue; diff --git a/code/game/g_svcmds.c b/code/game/g_svcmds.c index b251ab35..755a7da3 100644 --- a/code/game/g_svcmds.c +++ b/code/game/g_svcmds.c @@ -132,11 +132,11 @@ UpdateIPBans */ static void UpdateIPBans (void) { - byte b[4]; - byte m[4]; + byte b[4] = {0}; + byte m[4] = {0}; int i,j; - char iplist_final[MAX_CVAR_VALUE_STRING]; - char ip[64]; + char iplist_final[MAX_CVAR_VALUE_STRING] = {0}; + char ip[64] = {0}; *iplist_final = 0; for (i = 0 ; i < numIPFilters ; i++) @@ -178,7 +178,7 @@ qboolean G_FilterPacket (char *from) { int i; unsigned in; - byte m[4]; + byte m[4] = {0}; char *p; i = 0; diff --git a/code/opus-1.1/src/opus_decoder.c b/code/opus-1.1/src/opus_decoder.c index 4d03770d..0ba3a058 100644 --- a/code/opus-1.1/src/opus_decoder.c +++ b/code/opus-1.1/src/opus_decoder.c @@ -215,7 +215,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, VARDECL(opus_val16, pcm_transition_silk); int pcm_transition_celt_size; VARDECL(opus_val16, pcm_transition_celt); - opus_val16 *pcm_transition; + opus_val16 *pcm_transition=NULL; int redundant_audio_size; VARDECL(opus_val16, redundant_audio); diff --git a/code/opusfile-0.5/src/opusfile.c b/code/opusfile-0.5/src/opusfile.c index aaabdd1c..73b95de6 100644 --- a/code/opusfile-0.5/src/opusfile.c +++ b/code/opusfile-0.5/src/opusfile.c @@ -317,7 +317,7 @@ struct OpusSeekRecord{ static int op_get_prev_page_serial(OggOpusFile *_of,OpusSeekRecord *_sr, opus_int64 _offset,ogg_uint32_t _serialno, const ogg_uint32_t *_serialnos,int _nserialnos){ - OpusSeekRecord preferred_sr; + OpusSeekRecord preferred_sr={0}; ogg_page og; opus_int64 begin; opus_int64 end; @@ -930,7 +930,7 @@ static int op_find_initial_pcm_offset(OggOpusFile *_of, prev_packet_gp=pcm_start; for(pi=0;pi=0); @@ -2170,7 +2170,7 @@ static int op_pcm_seek_page(OggOpusFile *_of, ogg_int64_t pcm_start; ogg_int64_t pcm_end; ogg_int64_t best_gp; - ogg_int64_t diff; + ogg_int64_t diff=0; ogg_uint32_t serialno; opus_int32 pre_skip; opus_int64 begin; @@ -2289,7 +2289,7 @@ static int op_pcm_seek_page(OggOpusFile *_of, d2=end-begin>>1; if(force_bisect)bisect=begin+(end-begin>>1); else{ - ogg_int64_t diff2; + ogg_int64_t diff2=0; OP_ALWAYS_TRUE(!op_granpos_diff(&diff,_target_gp,pcm_start)); OP_ALWAYS_TRUE(!op_granpos_diff(&diff2,pcm_end,pcm_start)); /*Take a (pretty decent) guess.*/ @@ -2503,7 +2503,7 @@ static ogg_int64_t op_get_pcm_offset(const OggOpusFile *_of, ogg_int64_t _gp,int _li){ const OggOpusLink *links; ogg_int64_t pcm_offset; - ogg_int64_t delta; + ogg_int64_t delta=0; int li; links=_of->links; pcm_offset=0; diff --git a/code/qcommon/md4.c b/code/qcommon/md4.c index b37c87b4..0eb23a50 100644 --- a/code/qcommon/md4.c +++ b/code/qcommon/md4.c @@ -177,12 +177,10 @@ static void mdfour_update(struct mdfour *md, byte *in, int n) static void mdfour_result(struct mdfour *md, byte *out) { - m = md; - - copy4(out, m->A); - copy4(out+4, m->B); - copy4(out+8, m->C); - copy4(out+12, m->D); + copy4(out, md->A); + copy4(out+4, md->B); + copy4(out+8, md->C); + copy4(out+12, md->D); } static void mdfour(byte *out, byte *in, int n) diff --git a/code/qcommon/msg.c b/code/qcommon/msg.c index 5623b9bb..397c603e 100644 --- a/code/qcommon/msg.c +++ b/code/qcommon/msg.c @@ -246,7 +246,7 @@ int MSG_ReadBits( msg_t *msg, int bits ) { } msg->readcount = (msg->bit>>3)+1; } - if ( sgn ) { + if ( sgn && bits > 0 && bits < 32 ) { if ( value & ( 1 << ( bits - 1 ) ) ) { value |= -1 ^ ( ( 1 << bits ) - 1 ); } diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index 4ef3e345..98555b99 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -1619,7 +1619,7 @@ Called from NET_Sleep which uses select() to determine which sockets have seen a void NET_Event(fd_set *fdr) { byte bufData[MAX_MSGLEN + 1]; - netadr_t from; + netadr_t from = {0}; msg_t netmsg; while(1) diff --git a/code/renderergl1/tr_bsp.c b/code/renderergl1/tr_bsp.c index 64f6a565..ff623ad9 100644 --- a/code/renderergl1/tr_bsp.c +++ b/code/renderergl1/tr_bsp.c @@ -927,7 +927,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { for (m = 0; m < 2; m++) { - if ( grid2->width >= MAX_GRID_SIZE ) + if ( !grid2 || grid2->width >= MAX_GRID_SIZE ) break; if (m) offset2 = (grid2->height-1) * grid2->width; else offset2 = 0; @@ -971,7 +971,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { } for (m = 0; m < 2; m++) { - if (grid2->height >= MAX_GRID_SIZE) + if (!grid2 || grid2->height >= MAX_GRID_SIZE) break; if (m) offset2 = grid2->width-1; else offset2 = 0; @@ -1026,7 +1026,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { for (k = grid1->height-1; k > 1; k -= 2) { for (m = 0; m < 2; m++) { - if ( grid2->width >= MAX_GRID_SIZE ) + if ( !grid2 || grid2->width >= MAX_GRID_SIZE ) break; if (m) offset2 = (grid2->height-1) * grid2->width; else offset2 = 0; diff --git a/code/renderergl1/tr_shader.c b/code/renderergl1/tr_shader.c index 4e2e6f6c..fb813f2f 100644 --- a/code/renderergl1/tr_shader.c +++ b/code/renderergl1/tr_shader.c @@ -2915,7 +2915,7 @@ a single large text block that can be scanned for shader names static void ScanAndLoadShaderFiles( void ) { char **shaderFiles; - char *buffers[MAX_SHADER_FILES]; + char *buffers[MAX_SHADER_FILES] = {0}; char *p; int numShaderFiles; int i; diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index 2fcb58bd..98e89dd0 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -719,6 +719,7 @@ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *t qboolean tried[ NUM_DIALOG_PROGRAMS ] = { qfalse }; dialogCommandBuilder_t commands[ NUM_DIALOG_PROGRAMS ] = { NULL }; dialogCommandType_t preferredCommandType = NONE; + int i; commands[ ZENITY ] = &Sys_ZenityCommand; commands[ KDIALOG ] = &Sys_KdialogCommand; @@ -730,50 +731,37 @@ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *t else if( !Q_stricmp( session, "kde" ) ) preferredCommandType = KDIALOG; - while( 1 ) + for( i = NONE + 1; i < NUM_DIALOG_PROGRAMS; i++ ) { - int i; + if( preferredCommandType != NONE && preferredCommandType != i ) + continue; - for( i = NONE + 1; i < NUM_DIALOG_PROGRAMS; i++ ) + if( !tried[ i ] ) { - if( preferredCommandType != NONE && preferredCommandType != i ) - continue; + int exitCode; - if( !tried[ i ] ) + commands[ i ]( type, message, title ); + exitCode = Sys_Exec( ); + + if( exitCode >= 0 ) { - int exitCode; - - commands[ i ]( type, message, title ); - exitCode = Sys_Exec( ); - - if( exitCode >= 0 ) + switch( type ) { - switch( type ) - { - case DT_YES_NO: return exitCode ? DR_NO : DR_YES; - case DT_OK_CANCEL: return exitCode ? DR_CANCEL : DR_OK; - default: return DR_OK; - } - } - - tried[ i ] = qtrue; - - // The preference failed, so start again in order - if( preferredCommandType != NONE ) - { - preferredCommandType = NONE; - break; + case DT_YES_NO: return exitCode ? DR_NO : DR_YES; + case DT_OK_CANCEL: return exitCode ? DR_CANCEL : DR_OK; + default: return DR_OK; } } - } - for( i = NONE + 1; i < NUM_DIALOG_PROGRAMS; i++ ) - { - if( !tried[ i ] ) - continue; - } + tried[ i ] = qtrue; - break; + // The preference failed, so start again in order + if( preferredCommandType != NONE ) + { + preferredCommandType = NONE; + i = NONE + 1; + } + } } Com_DPrintf( S_COLOR_YELLOW "WARNING: failed to show a dialog\n" ); diff --git a/code/ui/ui_players.c b/code/ui/ui_players.c index e6355690..614cfb8d 100644 --- a/code/ui/ui_players.c +++ b/code/ui/ui_players.c @@ -690,12 +690,12 @@ UI_DrawPlayer */ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) { refdef_t refdef; - refEntity_t legs; - refEntity_t torso; - refEntity_t head; - refEntity_t gun; - refEntity_t barrel; - refEntity_t flash; + refEntity_t legs = {0}; + refEntity_t torso = {0}; + refEntity_t head = {0}; + refEntity_t gun = {0}; + refEntity_t barrel = {0}; + refEntity_t flash = {0}; vec3_t origin; int renderfx; vec3_t mins = {-16, -16, -24}; diff --git a/code/ui/ui_shared.c b/code/ui/ui_shared.c index a7bdd31c..f200202d 100644 --- a/code/ui/ui_shared.c +++ b/code/ui/ui_shared.c @@ -417,6 +417,8 @@ qboolean PC_Int_Parse(int handle, int *i) { pc_token_t token; int negative = qfalse; + if (!i) + return qfalse; if (!trap_PC_ReadToken(handle, &token)) return qfalse; if (token.string[0] == '-') { @@ -606,7 +608,7 @@ void Fade(int *flags, float *f, float clamp, int *nextTime, int offsetTime, qboo void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle) { //float bordersize = 0; - vec4_t color; + vec4_t color = {0}; rectDef_t fillRect = w->rect; @@ -4128,6 +4130,10 @@ menuDef_t *Menus_ActivateByName(const char *p) { void Item_Init(itemDef_t *item) { + if (item == NULL) { + return; + } + memset(item, 0, sizeof(itemDef_t)); item->textscale = 0.55f; Window_Init(&item->window);