Hoist strlen() outside loop in kzopen()

git-svn-id: https://svn.eduke32.com/eduke32@7025 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-10-07 05:22:08 +00:00
parent a677b18b2d
commit eeba7847eb

View file

@ -2632,11 +2632,14 @@ intptr_t kzopen(const char *filnam)
}
//Finally, check mounted dirs
int const namlen = strlen(filnam);
for (i=kzdirnamhead; i>=0; i=B_UNBUF32(&kzhashbuf[i]))
{
strcpy(tempbuf,&kzhashbuf[i+4]);
j = strlen(tempbuf);
if (strlen(filnam)+1+j >= sizeof(tempbuf)) continue; //don't allow int32_t filenames to buffer overrun
uint32_t const j = strlen(tempbuf);
if (namlen+1+j >= sizeof(tempbuf)) continue; //don't allow int32_t filenames to buffer overrun
if ((j) && (tempbuf[j-1] != '/') && (tempbuf[j-1] != '\\') && (filnam[0] != '/') && (filnam[0] != '\\'))
#if defined(_WIN32)
strcat(tempbuf,"\\");