Skip to content

Commit 8b24c04

Browse files
committed
avoid out of bounds accesses identified with Xcode's address sanitiser
mdsprite loadkvx("uziclip.kvx") in Shadow Warrior.
1 parent fd5d5b6 commit 8b24c04

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

src/mdsprite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ static int loadkvx (const char *filnam)
16631663
{ kread(fil,c,3); pal[i] = B_LITTLE32((((int)c[0])<<18)+(((int)c[1])<<10)+(((int)c[2])<<2)+(i<<24)); }
16641664

16651665
yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3);
1666-
vbit = (int *)malloc(i); if (!vbit) { free(xyoffs); kclose(fil); return(-1); }
1666+
vbit = (int *)malloc(i+1); if (!vbit) { free(xyoffs); kclose(fil); return(-1); }
16671667
memset(vbit,0,i);
16681668

16691669
for(vcolhashsizm1=4096;vcolhashsizm1<(mip1leng>>1);vcolhashsizm1<<=1) ;

src/sdlayer2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ int initinput(void)
415415
}
416416
if (dbuf) {
417417
flen = kread(fh, dbuf, flen);
418-
dbuf[flen+1] = 0;
419418
kclose(fh);
420419
if (flen >= 0) {
421420
rwops = SDL_RWFromConstMem(dbuf, flen);

0 commit comments

Comments
 (0)