From eeba7847eb948a4658dfe0803244333d0c8e3f35 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 7 Oct 2018 05:22:08 +0000 Subject: [PATCH] Hoist strlen() outside loop in kzopen() git-svn-id: https://svn.eduke32.com/eduke32@7025 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/kplib.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/build/src/kplib.cpp b/source/build/src/kplib.cpp index a484c0bc3..08598dcf9 100644 --- a/source/build/src/kplib.cpp +++ b/source/build/src/kplib.cpp @@ -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,"\\");