VOGONS


Pointer comparison bug

Topic actions

First post, by danoon

User metadata
Rank Member
Rank
Member

svn 3666 changed numRec from Bit16u to Bit16u*, but the statement below "if (numRec>0)" was not changed to "if (numRec && *numRec>0)". This will prevent the path of passing in a pointer holding 0 from working.

dos/dos_files.cpp

Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore) {
/* see FCB_RandomRead */
DOS_FCB fcb(seg,offset);
Bit32u random;
Bit16u old_block=0;
Bit8u old_rec=0;
Bit8u error=0;
Bit16u count;

/* Set the correct record from the random data */
fcb.GetRandom(random);
fcb.SetRecord((Bit16u)(random / 128),(Bit8u)(random & 127));
if (restore) fcb.GetRecord(old_block,old_rec);
if (numRec>0) {
/* Write records */
for (count=0; count<*numRec; count++) {
error = DOS_FCBWrite(seg,offset,count);// dos_fcbwrite return 0 false when true...
if (error!=FCB_SUCCESS) break;
}
*numRec=count;
} else {
DOS_FCBIncreaseSize(seg,offset);
}