Fix some potentially garbage assignments.

These are the ones where I could easily make scan-build happy. They do seem
to be potential holes where invalid data in one place could result in use
of uninitialized values.
This commit is contained in:
Bill Currie 2018-09-09 09:54:16 +09:00
parent 59e85b7d5e
commit 62793b2dc2
5 changed files with 15 additions and 4 deletions

View file

@ -222,7 +222,7 @@ SubdividePolygon (int numverts, float *verts)
vec3_t mins, maxs; vec3_t mins, maxs;
vec3_t front[64], back[64]; vec3_t front[64], back[64];
if (numverts > 60) if (numverts < 3 || numverts > 60)
Sys_Error ("numverts = %i", numverts); Sys_Error ("numverts = %i", numverts);
BoundPoly (numverts, verts, mins, maxs); BoundPoly (numverts, verts, mins, maxs);
@ -317,5 +317,7 @@ gl_Mod_SubdivideSurface (msurface_t *fa)
numverts++; numverts++;
} }
SubdividePolygon (numverts, verts[0]); if (numverts > 3) {
SubdividePolygon (numverts, verts[0]);
}
} }

View file

@ -387,7 +387,7 @@ PartialIPAddress (const char *in, netadr_t *hostaddr)
{ {
char *buff; char *buff;
char *b; char *b;
int addr, mask, num, port, run; unsigned addr, mask, num, port, run;
buff = nva (".%s", in); buff = nva (".%s", in);
b = buff; b = buff;
@ -407,7 +407,7 @@ PartialIPAddress (const char *in, netadr_t *hostaddr)
} }
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0) if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
goto error; goto error;
if (num < 0 || num > 255) if (num > 255)
goto error; goto error;
mask <<= 8; mask <<= 8;
addr = (addr << 8) + num; addr = (addr << 8) + num;

View file

@ -72,6 +72,8 @@ D_DrawSkyScans (espan_t *pspan)
sstep = 0; // keep compiler happy sstep = 0; // keep compiler happy
tstep = 0; // ditto tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do { do {
pdest = (unsigned char *) ((byte *) d_viewbuffer + pdest = (unsigned char *) ((byte *) d_viewbuffer +

View file

@ -79,6 +79,8 @@ sw32_D_DrawSkyScans (espan_t *pspan)
sstep = 0; // keep compiler happy sstep = 0; // keep compiler happy
tstep = 0; // ditto tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do { do {
pdest = (byte *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u; pdest = (byte *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u;
@ -146,6 +148,8 @@ sw32_D_DrawSkyScans (espan_t *pspan)
sstep = 0; // keep compiler happy sstep = 0; // keep compiler happy
tstep = 0; // ditto tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do { do {
pdest = (short *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u; pdest = (short *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u;
@ -213,6 +217,8 @@ sw32_D_DrawSkyScans (espan_t *pspan)
sstep = 0; // keep compiler happy sstep = 0; // keep compiler happy
tstep = 0; // ditto tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do { do {
pdest = (int *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u; pdest = (int *) sw32_d_viewbuffer + sw32_screenwidth * pspan->v + pspan->u;

View file

@ -657,6 +657,7 @@ Host_Loadgame_f (void)
game = convert_to_game_dict (script); game = convert_to_game_dict (script);
} }
memset (spawn_parms, 0, sizeof (spawn_parms));
item = PL_ObjectForKey (game, "spawn_parms"); item = PL_ObjectForKey (game, "spawn_parms");
for (i = 0; i < NUM_SPAWN_PARMS; i++) { for (i = 0; i < NUM_SPAWN_PARMS; i++) {
if (i >= PL_A_NumObjects (item)) if (i >= PL_A_NumObjects (item))