fix a few memory access bugs

This commit is contained in:
Bill Currie 2002-09-20 22:44:29 +00:00
parent 00294f7ae0
commit dd5cac488c
3 changed files with 17 additions and 11 deletions

View file

@ -453,7 +453,7 @@ void
LightFace (int surfnum)
{
int ofs;
byte *out;
byte *out, *outdata;
dface_t *f;
int lightmapwidth, lightmapsize, size, c, i, j, s, t, w, h;
lightinfo_t l;
@ -516,7 +516,7 @@ LightFace (int surfnum)
lightmapsize = size * l.numlightstyles;
LOCK;
out = malloc (lightmapsize);
outdata = out = malloc (lightmapsize);
UNLOCK;
ofs = GetFileSpace (lightmapsize);
f->lightofs = ofs;
@ -550,7 +550,7 @@ LightFace (int surfnum)
}
}
LOCK;
memcpy (lightdata->str + ofs, out, lightmapsize);
free (out);
memcpy (lightdata->str + ofs, outdata, lightmapsize);
free (outdata);
UNLOCK;
}

View file

@ -83,7 +83,7 @@ GetFileSpace (int size)
int ofs;
LOCK;
lightdata->size = (lightdata->size + 3) & 3;
lightdata->size = (lightdata->size + 3) & ~3;
ofs = lightdata->size;
lightdata->size += size;
dstring_adjust (lightdata);