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 front[64], back[64];
if (numverts > 60)
if (numverts < 3 || numverts > 60)
Sys_Error ("numverts = %i", numverts);
BoundPoly (numverts, verts, mins, maxs);
@ -317,5 +317,7 @@ gl_Mod_SubdivideSurface (msurface_t *fa)
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 *b;
int addr, mask, num, port, run;
unsigned addr, mask, num, port, run;
buff = nva (".%s", in);
b = buff;
@ -407,7 +407,7 @@ PartialIPAddress (const char *in, netadr_t *hostaddr)
}
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
goto error;
if (num < 0 || num > 255)
if (num > 255)
goto error;
mask <<= 8;
addr = (addr << 8) + num;

View file

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

View file

@ -79,6 +79,8 @@ sw32_D_DrawSkyScans (espan_t *pspan)
sstep = 0; // keep compiler happy
tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do {
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
tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do {
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
tstep = 0; // ditto
snext = 0; // ditto
tnext = 0; // ditto
do {
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);
}
memset (spawn_parms, 0, sizeof (spawn_parms));
item = PL_ObjectForKey (game, "spawn_parms");
for (i = 0; i < NUM_SPAWN_PARMS; i++) {
if (i >= PL_A_NumObjects (item))