Skip to content

Commit

Permalink
cgame: prevent unitialized scalar variable offset for brass ejection …
Browse files Browse the repository at this point in the history
…(coverity)

eFlags is not supposed to store MOUNTED _TANK and MG42/AAGUN_ACTIVE simultaneously. But to prevent any error we initialize the value.
  • Loading branch information
Aranud committed Mar 13, 2019
1 parent 69d5c67 commit 5f20389
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cgame/cg_weapons.c
Expand Up @@ -116,7 +116,7 @@ void CG_MachineGunEjectBrass(centity_t *cent)
localEntity_t *le;
refEntity_t *re;
vec3_t velocity, xvelocity;
vec3_t offset, xoffset;
vec3_t offset = { 0, 0, 0 };
float waterScale = 1.0f;
vec3_t v[3], end;
qboolean isFirstPerson = ((cent->currentState.clientNum == cg.snap->ps.clientNum) && !cg.renderingThirdPerson);
Expand Down Expand Up @@ -197,6 +197,8 @@ void CG_MachineGunEjectBrass(centity_t *cent)

if ((cent->currentState.eFlags & EF_MG42_ACTIVE) || (cent->currentState.eFlags & EF_AAGUN_ACTIVE) || !isFirstPerson)
{
vec3_t xoffset;

xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];
Expand Down

0 comments on commit 5f20389

Please sign in to comment.